ghu.task('build:script', runtime => { const webpackConfig = { mode: 'none', output: { library: NAME, libraryTarget: 'umd', umdNamedDefine: true, globalObject: '(typeof self !== \'undefined\' ? self : this)' }, module: { rules: [ { include: [SRC], loader: 'babel-loader', query: { cacheDirectory: true, presets: ['@babel/preset-env'] } } ] } }; return read(`${SRC}/${NAME}.js`) .then(webpack(webpackConfig, {showStats: false})) .then(includeit()) .then(uglify()) .then(wrap(runtime.commentJs)) .then(write(`${DIST}/${NAME}.min.js`, {overwrite: true})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true})); });
ghu.task('build:copy', () => { return Promise.all([ read(`${VENDOR}/demo/*`) .then(write(mapfn.p(VENDOR, BUILD), {overwrite: true})), read(`${ROOT}/*.md`) .then(write(mapfn.p(ROOT, BUILD), {overwrite: true})) ]); });
ghu.task('build:demo', runtime => { return Promise.all([ read(`${DEMO}/*.pug`) .then(pug({pkg: runtime.pkg})) .then(write(mapfn.p(SRC, BUILD).s('.pug', ''), {overwrite: true})), read(`${DEMO}: *, !*.pug`) .then(write(mapfn.p(SRC, BUILD), {overwrite: true})) ]); });
ghu.task('build:demo', runtime => { return Promise.all([ read(`${SRC}/demo/*.jade`) .then(jade({pkg: runtime.pkg})) .then(write(mapfn.p(SRC, BUILD).s('.jade', ''), {overwrite: true})), read(`${SRC}/demo/*, !**/*.jade`) .then(write(mapfn.p(SRC, BUILD), {overwrite: true})) ]); });
ghu.task('build:scripts', runtime => { return read(`${SRC}/${NAME}.js`) .then(wrap(runtime.comment_js)) .then(write(`${DIST}/${NAME}.js`, {overwrite: true})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.js`, {overwrite: true})) .then(uglify()) .then(wrap(runtime.comment_js)) .then(write(`${DIST}/${NAME}.min.js`, {overwrite: true})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true})); });
ghu.task('build:scripts', runtime => { return read(`${SRC}/*.js`) .then(babel({presets: ['@babel/preset-env']})) .then(wrap(runtime.commentJs)) .then(write(mapfn.p(SRC, DIST), {overwrite: true})) .then(write(mapfn.p(SRC, BUILD).s('.js', `-${runtime.pkg.version}.js`), {overwrite: true})) .then(uglify()) .then(wrap(runtime.commentJs)) .then(write(mapfn.p(SRC, DIST).s('.js', '.min.js'), {overwrite: true})) .then(write(mapfn.p(SRC, BUILD).s('.js', `-${runtime.pkg.version}.min.js`), {overwrite: true})); });
ghu.task('build:script', runtime => { return read(`${SRC}/${runtime.pkg.name}.js`) .then(webpack(webpack.cfg_umd(NAME, [SRC]))) .then(wrap(runtime.commentJs)) .then(write(`${DIST}/${runtime.pkg.name}.js`, {overwrite: true})) .then(write(`${BUILD}/${runtime.pkg.name}-${runtime.pkg.version}.js`, {overwrite: true})) .then(uglify()) .then(wrap(runtime.commentJs)) .then(write(`${DIST}/${runtime.pkg.name}.min.js`, {overwrite: true})) .then(write(`${BUILD}/${runtime.pkg.name}-${runtime.pkg.version}.min.js`, {overwrite: true})); });
ghu.task('build:scripts', runtime => { return read(`${SRC}/${NAME}.js`) .then(includeit()) .then(wrap(runtime.commentJs)) .then(write(`${DIST}/${NAME}.js`, {overwrite: true})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.js`, {overwrite: true})) .then(uglify({compressor: {warnings: false}})) .then(wrap(runtime.commentJs)) .then(write(`${DIST}/${NAME}.min.js`, {overwrite: true})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.min.js`, {overwrite: true})); });
ghu.task('build:other', runtime => { return Promise.all([ read(`${SRC}/**/*.pug`) .then(pug({pkg: runtime.pkg})) .then(write(mapfn.p(SRC, BUILD).s('.pug', ''), {overwrite: true})), read(`${SRC}/**/*.less`) .then(includeit()) .then(less()) .then(cssmin()) .then(write(mapfn.p(SRC, BUILD).s('.less', '.css'), {overwrite: true})), read(`${SRC}/demo/*.js, ${SRC}/test/*.js`) .then(babel({presets: ['@babel/preset-env']})) .then(uglify()) .then(wrap(runtime.commentJs)) .then(write(mapfn.p(SRC, BUILD), {overwrite: true})), read(`${ROOT}/node_modules/scar/dist/scar.min.js`) .then(write(`${BUILD}/test/scar.min.js`, {overwrite: true})), read(`${ROOT}/node_modules/jquery/dist/jquery.min.js`) .then(write(`${BUILD}/demo/jquery.min.js`, {overwrite: true})) .then(write(`${BUILD}/test/jquery.min.js`, {overwrite: true})), read(`${ROOT}/*.md`) .then(write(mapfn.p(ROOT, BUILD), {overwrite: true})) ]); });
ghu.task('build:demo', runtime => { return read(`${SRC}/demo.html`) .then(each(obj => { obj.content = obj.content .replace(/lolight demo/g, `${NAME} v${runtime.pkg.version} demo`) .replace(/"lolight\.js"/g, `"${NAME}-${runtime.pkg.version}.min.js"`); })) .then(wrap('', runtime.comment_html)) .then(write(`${BUILD}/demo.html`, {overwrite: true})); });
ghu.task('zip', ['build'], runtime => { return read(`${BUILD}/**/*`) .then(jszip({dir: BUILD, level: 9})) .then(write(`${BUILD}/${NAME}-${runtime.pkg.version}.zip`, {overwrite: true})); });
const overwrite = arg => write(arg, {overwrite: true});
ghu.task('build:copy', () => { return read(`${ROOT}/*.md`) .then(write(mapfn.p(ROOT, BUILD), {overwrite: true})); });