[refactor] streamline gulp javascript pipelines

This commit is contained in:
Giacomo Rossetto 2019-08-25 23:27:11 +02:00 committed by Kombie
parent b727679f7f
commit 4a77fd43c7
3 changed files with 427 additions and 469 deletions

View File

@ -1,7 +1,6 @@
const {
src,
dest,
series,
parallel
} = require('gulp');
@ -17,7 +16,7 @@ const htmlmin = require('gulp-htmlmin');
const watch = require('gulp-watch');
const clean = require('gulp-clean');
const filter = require('gulp-filter');
const path = {
src: 'src',
@ -28,8 +27,6 @@ const path = {
const filename = {
css: 'nighttab.min.css',
jsDependencies: 'nighttab.dependencies.js',
jsFiles: 'nighttab.files.js',
js: 'nighttab.min.js'
}
@ -96,43 +93,20 @@ const build = {
.pipe(csso())
.pipe(dest(path.build + '/css'))
},
jsDependencies: function() {
return src(jsDependencies, {
sourcemaps: true
})
.pipe(concat(filename.jsDependencies))
.pipe(dest(path.build + '/js', {
sourcemaps: true
}))
},
jsFiles: function() {
return src(jsFiles, {
sourcemaps: true
})
.pipe(concat(filename.jsFiles))
.pipe(uglify())
.pipe(dest(path.build + '/js', {
sourcemaps: true
}))
},
js: function() {
return src([
path.build + '/js/' + filename.jsDependencies,
path.build + '/js/' + filename.jsFiles
], {
const noVendors = filter(jsFiles, {
restore: true
});
return src(jsDependencies.concat(jsFiles), {
sourcemaps: true
})
.pipe(noVendors)
.pipe(uglify())
.pipe(noVendors.restore)
.pipe(concat(filename.js))
.pipe(dest(path.build + '/js', {
sourcemaps: '.'
}))
},
jsClean: function() {
return src([
path.build + '/js/' + filename.jsDependencies,
path.build + '/js/' + filename.jsFiles
])
.pipe(clean())
}
}
@ -188,4 +162,4 @@ const dev = {
}
exports.dev = parallel(dev.manifest, dev.html, dev.fonts, dev.icons, dev.css, dev.js)
exports.build = series(parallel(build.manifest, build.html, build.fonts, build.icons, build.css), series(build.jsDependencies, build.jsFiles, build.js), build.jsClean)
exports.build = parallel(build.manifest, build.html, build.fonts, build.icons, build.css, build.js)

850
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,10 +40,10 @@
"devDependencies": {
"gh-pages": "^2.1.1",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-cli": "^2.2.0",
"gulp-concat": "^2.6.1",
"gulp-csso": "^3.0.1",
"gulp-filter": "^6.0.0",
"gulp-htmlmin": "^5.0.1",
"gulp-replace": "^1.0.0",
"gulp-uglify": "^3.0.2",