#32 Changed build script to handle multiple JS "bundles" as preparation for settings

Also requires gulp-merge and factor-bundle as new devDependencies.
This commit is contained in:
Serraniel 2020-11-07 14:43:20 +01:00
parent 74f48818e4
commit 65cb380735
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3
5 changed files with 414 additions and 6 deletions

View file

@ -9,6 +9,8 @@ const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const merge = require('merge-stream');
const fs = require('fs');
const factor = require('factor-bundle');
const { debug } = require('console');
const $ = gulpLoadPlugins()
@ -113,14 +115,33 @@ gulp.task('styles', () => {
})
gulp.task('scripts', () => {
let b = browserify({
entries: `${src.scripts}/index.js`,
debug: isDev
const modules = [
'app',
'settings',
];
const inputs = [];
const streams = [];
modules.forEach(module => {
inputs.push(`${src.scripts}/${module}.js`);
streams.push(source(`${module}.js`));
});
return b.transform('babelify').bundle()
const b = browserify(inputs, { debug: isDev });
let outstream = b
.transform('babelify')
.plugin(factor, { outputs: streams })
.bundle()
.pipe(source('common.js'))
streams.forEach(stream => {
outstream = outstream.pipe($.merge(stream));
});
return outstream
.pipe($.plumber())
.pipe(source('app.js'))
.pipe(buffer())
.pipe($.if(isDev, $.sourcemaps.init({ loadMaps: true })))
.pipe($.terser({ compress: { drop_console: isProd, drop_debugger: isProd } }))
@ -129,7 +150,7 @@ gulp.task('scripts', () => {
showFiles: true,
}))
.pipe($.if(isDev, $.sourcemaps.write()))
.pipe(gulp.dest(`${tmp.scripts}`))
.pipe(gulp.dest(`${tmp.scripts}`));
})
gulp.task('images', () => {

374
package-lock.json generated
View file

@ -4306,6 +4306,41 @@
"through2": "^2.0.0"
}
},
"deps-topo-sort": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/deps-topo-sort/-/deps-topo-sort-0.2.1.tgz",
"integrity": "sha1-S+ivB0dpcWSciwxIT9fUqHuLASo=",
"dev": true,
"requires": {
"JSONStream": "~0.7.1",
"minimist": "0.0.5",
"through": "~2.3.4"
},
"dependencies": {
"JSONStream": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.7.4.tgz",
"integrity": "sha1-c0KQ5BUR7qfCz+FR+/mlY6l7l4Y=",
"dev": true,
"requires": {
"jsonparse": "0.0.5",
"through": ">=2.2.7 <3"
}
},
"jsonparse": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
"integrity": "sha1-MwVCrT8KZUZlt3jz6y2an6UHrGQ=",
"dev": true
},
"minimist": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
"integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=",
"dev": true
}
}
},
"des.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
@ -5066,6 +5101,228 @@
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"dev": true
},
"factor-bundle": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/factor-bundle/-/factor-bundle-2.5.0.tgz",
"integrity": "sha1-jqiVfaOddYYoPMPuNTzZkRpF53k=",
"dev": true,
"requires": {
"JSONStream": "~0.8.4",
"browser-pack": "^5.0.1",
"defined": "0.0.0",
"deps-topo-sort": "~0.2.1",
"inherits": "^2.0.1",
"isarray": "0.0.1",
"labeled-stream-splicer": "^1.0.0",
"minimist": "~0.2.0",
"nub": "0.0.0",
"outpipe": "^1.1.0",
"reversepoint": "~0.2.0",
"stream-combiner": "~0.2.1",
"through2": "^0.5.1",
"xtend": "^4.0.0"
},
"dependencies": {
"JSONStream": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz",
"integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=",
"dev": true,
"requires": {
"jsonparse": "0.0.5",
"through": ">=2.2.7 <3"
},
"dependencies": {
"jsonparse": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz",
"integrity": "sha1-MwVCrT8KZUZlt3jz6y2an6UHrGQ=",
"dev": true
}
}
},
"browser-pack": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-5.0.1.tgz",
"integrity": "sha1-QZdxmyDG4KqglFHFER5T77b7wY0=",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"combine-source-map": "~0.6.1",
"defined": "^1.0.0",
"through2": "^1.0.0",
"umd": "^3.0.0"
},
"dependencies": {
"JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
"integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
"dev": true,
"requires": {
"jsonparse": "^1.2.0",
"through": ">=2.2.7 <3"
}
},
"defined": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true
},
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"combine-source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.6.1.tgz",
"integrity": "sha1-m0oJwxYDPXaODxHgKfonMOB5rZY=",
"dev": true,
"requires": {
"convert-source-map": "~1.1.0",
"inline-source-map": "~0.5.0",
"lodash.memoize": "~3.0.3",
"source-map": "~0.4.2"
}
},
"convert-source-map": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
"integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
"dev": true
},
"defined": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz",
"integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=",
"dev": true
},
"inline-source-map": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.5.0.tgz",
"integrity": "sha1-Skxd2OT7Xps82mDIIt+tyu5m4K8=",
"dev": true,
"requires": {
"source-map": "~0.4.0"
}
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"labeled-stream-splicer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-1.0.2.tgz",
"integrity": "sha1-RhUzFTd4SYHo/SZOHzpDTE4N3WU=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"isarray": "~0.0.1",
"stream-splicer": "^1.1.0"
}
},
"minimist": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.1.tgz",
"integrity": "sha512-GY8fANSrTMfBVfInqJAY41QkOM+upUTytK1jZ0c8+3HdHrJxBJ3rF5i9moClXTE8uUSnUo8cAsCoxDXvSY4DHg==",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"source-map": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true,
"requires": {
"amdefine": ">=0.0.4"
}
},
"stream-splicer": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-1.3.2.tgz",
"integrity": "sha1-PARBvhW5v04iYnXm3IOWR0VUZmE=",
"dev": true,
"requires": {
"indexof": "0.0.1",
"inherits": "^2.0.1",
"isarray": "~0.0.1",
"readable-stream": "^1.1.13-1",
"readable-wrap": "^1.0.0",
"through2": "^1.0.0"
},
"dependencies": {
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"through2": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz",
"integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=",
"dev": true,
"requires": {
"readable-stream": "~1.0.17",
"xtend": "~3.0.0"
},
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"xtend": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz",
"integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=",
"dev": true
}
}
}
}
},
"fancy-log": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.3.tgz",
@ -6074,6 +6331,51 @@
"minimatch": "^3.0.3"
}
},
"gulp-merge": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/gulp-merge/-/gulp-merge-0.1.1.tgz",
"integrity": "sha1-pGLuARd6jqfEYPDqia1ULsdSujc=",
"dev": true,
"requires": {
"through2": "~1.1.1"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
},
"through2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-1.1.1.tgz",
"integrity": "sha1-CEfLxESfNAVXTb3M2buEG4OsNUU=",
"dev": true,
"requires": {
"readable-stream": ">=1.1.13-1 <1.2.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
}
}
},
"gulp-plumber": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.2.1.tgz",
@ -6855,6 +7157,12 @@
"integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=",
"dev": true
},
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -8369,6 +8677,12 @@
"boolbase": "~1.0.0"
}
},
"nub": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/nub/-/nub-0.0.0.tgz",
"integrity": "sha1-s2m9Mr3eZq9ZYFw7BSC8IZ3MwE8=",
"dev": true
},
"num2fraction": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz",
@ -8607,6 +8921,15 @@
"os-tmpdir": "^1.0.0"
}
},
"outpipe": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz",
"integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=",
"dev": true,
"requires": {
"shell-quote": "^1.4.2"
}
},
"p-cancelable": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz",
@ -10410,6 +10733,41 @@
}
}
},
"readable-wrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/readable-wrap/-/readable-wrap-1.0.0.tgz",
"integrity": "sha1-O1ohHGMeEjA6VJkcgGwX564ga/8=",
"dev": true,
"requires": {
"readable-stream": "^1.1.13-1"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"dev": true
}
}
},
"readdirp": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz",
@ -10819,6 +11177,12 @@
"integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
"dev": true
},
"reversepoint": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/reversepoint/-/reversepoint-0.2.1.tgz",
"integrity": "sha1-0qw/9NZlzw/3Ipa3p47nI39lk/U=",
"dev": true
},
"rgb-regex": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/rgb-regex/-/rgb-regex-1.0.1.tgz",
@ -11546,6 +11910,16 @@
}
}
},
"stream-combiner": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz",
"integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=",
"dev": true,
"requires": {
"duplexer": "~0.1.1",
"through": "~2.3.4"
}
},
"stream-combiner2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",

View file

@ -48,12 +48,14 @@
"cross-env": "^7.0.2",
"cssnano": "^4.1.10",
"del": "^6.0.0",
"factor-bundle": "^2.5.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-babel": "^8.0.0",
"gulp-if": "^3.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-load-plugins": "^2.0.5",
"gulp-merge": "^0.1.1",
"gulp-plumber": "^1.2.1",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",

View file

@ -0,0 +1,11 @@
import { onReady } from "./utils/helpers";
onReady(() => {
});
function saveOptions() {
}
document.getElementById('save').addEventListener('click', saveOptions)