[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 { const {
src, src,
dest, dest,
series,
parallel parallel
} = require('gulp'); } = require('gulp');
@ -17,7 +16,7 @@ const htmlmin = require('gulp-htmlmin');
const watch = require('gulp-watch'); const watch = require('gulp-watch');
const clean = require('gulp-clean'); const filter = require('gulp-filter');
const path = { const path = {
src: 'src', src: 'src',
@ -28,8 +27,6 @@ const path = {
const filename = { const filename = {
css: 'nighttab.min.css', css: 'nighttab.min.css',
jsDependencies: 'nighttab.dependencies.js',
jsFiles: 'nighttab.files.js',
js: 'nighttab.min.js' js: 'nighttab.min.js'
} }
@ -96,43 +93,20 @@ const build = {
.pipe(csso()) .pipe(csso())
.pipe(dest(path.build + '/css')) .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() { js: function() {
return src([ const noVendors = filter(jsFiles, {
path.build + '/js/' + filename.jsDependencies, restore: true
path.build + '/js/' + filename.jsFiles });
], { return src(jsDependencies.concat(jsFiles), {
sourcemaps: true sourcemaps: true
}) })
.pipe(noVendors)
.pipe(uglify())
.pipe(noVendors.restore)
.pipe(concat(filename.js)) .pipe(concat(filename.js))
.pipe(dest(path.build + '/js', { .pipe(dest(path.build + '/js', {
sourcemaps: '.' 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.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": { "devDependencies": {
"gh-pages": "^2.1.1", "gh-pages": "^2.1.1",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-cli": "^2.2.0", "gulp-cli": "^2.2.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-csso": "^3.0.1", "gulp-csso": "^3.0.1",
"gulp-filter": "^6.0.0",
"gulp-htmlmin": "^5.0.1", "gulp-htmlmin": "^5.0.1",
"gulp-replace": "^1.0.0", "gulp-replace": "^1.0.0",
"gulp-uglify": "^3.0.2", "gulp-uglify": "^3.0.2",