balm-core 5.2.0 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2191 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +559 -0
- package/dist/index.d.ts +559 -0
- package/dist/index.js +2098 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -123
- package/src/balm.ts +103 -0
- package/src/bundler/esbuild.ts +47 -0
- package/src/bundler/index.ts +3 -0
- package/src/bundler/rollup.ts +39 -0
- package/src/bundler/webpack.ts +82 -0
- package/src/config/constants.ts +12 -0
- package/src/config/defaults.ts +209 -0
- package/src/config/index.ts +112 -0
- package/src/hooks/index.ts +192 -0
- package/src/index.ts +16 -0
- package/src/pipeline/file.ts +69 -0
- package/src/pipeline/index.ts +10 -0
- package/src/pipeline/pipeline.ts +132 -0
- package/src/pipeline/transforms/cache.ts +96 -0
- package/src/pipeline/transforms/htmlmin.ts +18 -0
- package/src/pipeline/transforms/less.ts +75 -0
- package/src/pipeline/transforms/postcss.ts +43 -0
- package/src/pipeline/transforms/rename.ts +37 -0
- package/src/pipeline/transforms/replace.ts +30 -0
- package/src/pipeline/transforms/sass.ts +106 -0
- package/src/pipeline/transforms/terser.ts +20 -0
- package/src/runner/dag.ts +77 -0
- package/src/runner/task.ts +38 -0
- package/src/shims.d.ts +5 -0
- package/src/tasks/cache.ts +58 -0
- package/src/tasks/clean.ts +21 -0
- package/src/tasks/copy.ts +36 -0
- package/src/tasks/ftp.ts +90 -0
- package/src/tasks/html.ts +78 -0
- package/src/tasks/index.ts +13 -0
- package/src/tasks/publish.ts +71 -0
- package/src/tasks/pwa.ts +49 -0
- package/src/tasks/remove.ts +24 -0
- package/src/tasks/replace.ts +34 -0
- package/src/tasks/script.ts +28 -0
- package/src/tasks/server.ts +89 -0
- package/src/tasks/style.ts +57 -0
- package/src/tasks/zip.ts +65 -0
- package/src/types/index.ts +200 -0
- package/src/utilities/file.ts +120 -0
- package/src/utilities/logger.ts +63 -0
- package/src/utilities/utils.ts +46 -0
- package/src/utilities/workspace.ts +38 -0
- package/src/watcher/index.ts +100 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +12 -0
- package/README.md +0 -196
- package/index.d.ts +0 -360
- package/lib/balm.js +0 -49
- package/lib/bootstrap/check_config.js +0 -43
- package/lib/bootstrap/index.js +0 -87
- package/lib/bundler/esbuild/build.js +0 -26
- package/lib/bundler/esbuild/index.js +0 -7
- package/lib/bundler/esbuild/options.js +0 -7
- package/lib/bundler/esbuild/transform.js +0 -36
- package/lib/bundler/rollup/build.js +0 -52
- package/lib/bundler/rollup/entry.js +0 -28
- package/lib/bundler/rollup/index.js +0 -20
- package/lib/bundler/rollup/output.js +0 -20
- package/lib/bundler/rollup/plugins.js +0 -31
- package/lib/bundler/webpack/config/common.js +0 -135
- package/lib/bundler/webpack/config/dev.js +0 -12
- package/lib/bundler/webpack/config/env.js +0 -67
- package/lib/bundler/webpack/config/index.js +0 -6
- package/lib/bundler/webpack/config/prod.js +0 -39
- package/lib/bundler/webpack/config/regex.js +0 -10
- package/lib/bundler/webpack/entry.js +0 -65
- package/lib/bundler/webpack/index.js +0 -32
- package/lib/bundler/webpack/loaders.js +0 -50
- package/lib/bundler/webpack/output.js +0 -41
- package/lib/bundler/webpack/rules/asset.js +0 -33
- package/lib/bundler/webpack/rules/babel.js +0 -19
- package/lib/bundler/webpack/rules/css.js +0 -109
- package/lib/bundler/webpack/rules/html.js +0 -15
- package/lib/bundler/webpack/rules/index.js +0 -10
- package/lib/config/assets.js +0 -30
- package/lib/config/constants.js +0 -14
- package/lib/config/env.js +0 -35
- package/lib/config/extras.js +0 -6
- package/lib/config/ftp.js +0 -6
- package/lib/config/globals.js +0 -43
- package/lib/config/html.js +0 -22
- package/lib/config/images.js +0 -4
- package/lib/config/index.js +0 -63
- package/lib/config/logs.js +0 -11
- package/lib/config/paths.js +0 -46
- package/lib/config/pwa.js +0 -24
- package/lib/config/roots.js +0 -9
- package/lib/config/scripts.js +0 -162
- package/lib/config/server.js +0 -84
- package/lib/config/spinner.js +0 -9
- package/lib/config/styles.js +0 -67
- package/lib/hello.js +0 -19
- package/lib/hooks/index.js +0 -94
- package/lib/hooks/maker.js +0 -59
- package/lib/index.js +0 -5
- package/lib/middlewares/history.js +0 -6
- package/lib/middlewares/index.js +0 -11
- package/lib/middlewares/proxy.js +0 -28
- package/lib/middlewares/webpack.js +0 -26
- package/lib/plugins/htmlmin.js +0 -39
- package/lib/plugins/imagemin.js +0 -95
- package/lib/plugins/index.js +0 -27
- package/lib/plugins/jsmin.js +0 -37
- package/lib/plugins/less.js +0 -97
- package/lib/plugins/plumber.js +0 -87
- package/lib/plugins/postcss-plugins.js +0 -13
- package/lib/plugins/postcss.js +0 -117
- package/lib/plugins/rename.js +0 -51
- package/lib/plugins/replace.js +0 -91
- package/lib/plugins/sass-legacy.js +0 -131
- package/lib/plugins/sass.js +0 -134
- package/lib/plugins/sftp.js +0 -288
- package/lib/tasks/default.js +0 -46
- package/lib/tasks/foundation/balm.js +0 -72
- package/lib/tasks/foundation/balm_style.js +0 -65
- package/lib/tasks/foundation/index.js +0 -10
- package/lib/tasks/index.js +0 -48
- package/lib/tasks/private/build.js +0 -18
- package/lib/tasks/private/cache.js +0 -31
- package/lib/tasks/private/clean.js +0 -69
- package/lib/tasks/private/end.js +0 -24
- package/lib/tasks/private/extra.js +0 -35
- package/lib/tasks/private/font.js +0 -15
- package/lib/tasks/private/image.js +0 -37
- package/lib/tasks/private/index.js +0 -34
- package/lib/tasks/private/lint.js +0 -20
- package/lib/tasks/private/media.js +0 -15
- package/lib/tasks/private/modernizr.js +0 -59
- package/lib/tasks/private/pwa-cache.js +0 -32
- package/lib/tasks/private/script.js +0 -9
- package/lib/tasks/private/sprite.js +0 -105
- package/lib/tasks/private/start.js +0 -16
- package/lib/tasks/private/style.js +0 -9
- package/lib/tasks/private/workbox-sw.js +0 -15
- package/lib/tasks/public/copy.js +0 -16
- package/lib/tasks/public/esbuild.js +0 -18
- package/lib/tasks/public/ftp.js +0 -39
- package/lib/tasks/public/html.js +0 -65
- package/lib/tasks/public/index.js +0 -38
- package/lib/tasks/public/jsmin.js +0 -23
- package/lib/tasks/public/less.js +0 -21
- package/lib/tasks/public/postcss.js +0 -16
- package/lib/tasks/public/publish.js +0 -51
- package/lib/tasks/public/pwa.js +0 -84
- package/lib/tasks/public/remove.js +0 -46
- package/lib/tasks/public/replace.js +0 -26
- package/lib/tasks/public/rollup.js +0 -17
- package/lib/tasks/public/sass.js +0 -27
- package/lib/tasks/public/server.js +0 -130
- package/lib/tasks/public/url.js +0 -35
- package/lib/tasks/public/version.js +0 -23
- package/lib/tasks/public/webpack.js +0 -39
- package/lib/tasks/public/zip.js +0 -19
- package/lib/utilities/address.js +0 -55
- package/lib/utilities/cache-core.js +0 -66
- package/lib/utilities/color.js +0 -27
- package/lib/utilities/compiling.js +0 -24
- package/lib/utilities/detect-port.js +0 -100
- package/lib/utilities/escape-string-regexp.js +0 -10
- package/lib/utilities/file.js +0 -70
- package/lib/utilities/index.js +0 -8
- package/lib/utilities/loading.js +0 -37
- package/lib/utilities/logger.js +0 -99
- package/lib/utilities/merge-stream.js +0 -38
- package/lib/utilities/namespace.js +0 -11
- package/lib/utilities/public-url.js +0 -37
- package/lib/utilities/replacestream.js +0 -106
- package/lib/utilities/typeof.js +0 -5
- package/lib/utilities/utils.js +0 -43
- package/tslib/balm.js +0 -44
- package/tslib/bootstrap/check_config.js +0 -36
- package/tslib/bootstrap/index.js +0 -82
- package/tslib/bundler/esbuild/build.js +0 -30
- package/tslib/bundler/esbuild/index.js +0 -11
- package/tslib/bundler/esbuild/options.js +0 -7
- package/tslib/bundler/esbuild/transform.js +0 -38
- package/tslib/bundler/rollup/build.js +0 -17
- package/tslib/bundler/rollup/entry.js +0 -24
- package/tslib/bundler/rollup/index.js +0 -21
- package/tslib/bundler/rollup/output.js +0 -23
- package/tslib/bundler/rollup/plugins.js +0 -27
- package/tslib/bundler/webpack/config/common.js +0 -130
- package/tslib/bundler/webpack/config/dev.js +0 -14
- package/tslib/bundler/webpack/config/env.js +0 -44
- package/tslib/bundler/webpack/config/index.js +0 -8
- package/tslib/bundler/webpack/config/prod.js +0 -43
- package/tslib/bundler/webpack/config/regex.js +0 -10
- package/tslib/bundler/webpack/entry.js +0 -68
- package/tslib/bundler/webpack/index.js +0 -30
- package/tslib/bundler/webpack/loaders.js +0 -51
- package/tslib/bundler/webpack/output.js +0 -41
- package/tslib/bundler/webpack/rules/asset.js +0 -33
- package/tslib/bundler/webpack/rules/babel.js +0 -16
- package/tslib/bundler/webpack/rules/css.js +0 -95
- package/tslib/bundler/webpack/rules/html.js +0 -15
- package/tslib/bundler/webpack/rules/index.js +0 -10
- package/tslib/config/assets.js +0 -24
- package/tslib/config/constants.js +0 -14
- package/tslib/config/env.js +0 -43
- package/tslib/config/extras.js +0 -6
- package/tslib/config/ftp.js +0 -6
- package/tslib/config/globals.js +0 -47
- package/tslib/config/html.js +0 -17
- package/tslib/config/images.js +0 -4
- package/tslib/config/index.js +0 -56
- package/tslib/config/logs.js +0 -6
- package/tslib/config/paths.js +0 -30
- package/tslib/config/pwa.js +0 -18
- package/tslib/config/roots.js +0 -8
- package/tslib/config/scripts.js +0 -93
- package/tslib/config/server.js +0 -33
- package/tslib/config/spinner.js +0 -10
- package/tslib/config/styles.js +0 -37
- package/tslib/hello.js +0 -19
- package/tslib/hooks/index.js +0 -75
- package/tslib/hooks/maker.js +0 -66
- package/tslib/index.js +0 -5
- package/tslib/middlewares/history.js +0 -12
- package/tslib/middlewares/index.js +0 -18
- package/tslib/middlewares/proxy.js +0 -27
- package/tslib/middlewares/webpack.js +0 -29
- package/tslib/plugins/htmlmin.js +0 -38
- package/tslib/plugins/imagemin.js +0 -97
- package/tslib/plugins/index.js +0 -27
- package/tslib/plugins/jsmin.js +0 -39
- package/tslib/plugins/less.js +0 -90
- package/tslib/plugins/plumber.js +0 -81
- package/tslib/plugins/postcss-plugins.js +0 -24
- package/tslib/plugins/postcss.js +0 -111
- package/tslib/plugins/rename.js +0 -51
- package/tslib/plugins/replace.js +0 -72
- package/tslib/plugins/sass-legacy.js +0 -95
- package/tslib/plugins/sass.js +0 -109
- package/tslib/plugins/sftp.js +0 -258
- package/tslib/tasks/default.js +0 -59
- package/tslib/tasks/foundation/balm.js +0 -75
- package/tslib/tasks/foundation/balm_style.js +0 -68
- package/tslib/tasks/foundation/index.js +0 -10
- package/tslib/tasks/index.js +0 -43
- package/tslib/tasks/private/build.js +0 -15
- package/tslib/tasks/private/cache.js +0 -48
- package/tslib/tasks/private/clean.js +0 -82
- package/tslib/tasks/private/end.js +0 -21
- package/tslib/tasks/private/extra.js +0 -34
- package/tslib/tasks/private/font.js +0 -12
- package/tslib/tasks/private/image.js +0 -42
- package/tslib/tasks/private/index.js +0 -34
- package/tslib/tasks/private/lint.js +0 -17
- package/tslib/tasks/private/media.js +0 -12
- package/tslib/tasks/private/modernizr.js +0 -54
- package/tslib/tasks/private/pwa-cache.js +0 -32
- package/tslib/tasks/private/script.js +0 -9
- package/tslib/tasks/private/sprite.js +0 -93
- package/tslib/tasks/private/start.js +0 -13
- package/tslib/tasks/private/style.js +0 -12
- package/tslib/tasks/private/workbox-sw.js +0 -15
- package/tslib/tasks/public/copy.js +0 -18
- package/tslib/tasks/public/esbuild.js +0 -18
- package/tslib/tasks/public/ftp.js +0 -39
- package/tslib/tasks/public/html.js +0 -75
- package/tslib/tasks/public/index.js +0 -38
- package/tslib/tasks/public/jsmin.js +0 -24
- package/tslib/tasks/public/less.js +0 -21
- package/tslib/tasks/public/postcss.js +0 -16
- package/tslib/tasks/public/publish.js +0 -50
- package/tslib/tasks/public/pwa.js +0 -87
- package/tslib/tasks/public/remove.js +0 -44
- package/tslib/tasks/public/replace.js +0 -27
- package/tslib/tasks/public/rollup.js +0 -17
- package/tslib/tasks/public/sass.js +0 -27
- package/tslib/tasks/public/server.js +0 -129
- package/tslib/tasks/public/url.js +0 -35
- package/tslib/tasks/public/version.js +0 -27
- package/tslib/tasks/public/webpack.js +0 -41
- package/tslib/tasks/public/zip.js +0 -19
- package/tslib/utilities/address.js +0 -48
- package/tslib/utilities/cache-core.js +0 -57
- package/tslib/utilities/color.js +0 -33
- package/tslib/utilities/compiling.js +0 -16
- package/tslib/utilities/detect-port.js +0 -91
- package/tslib/utilities/escape-string-regexp.js +0 -7
- package/tslib/utilities/file.js +0 -78
- package/tslib/utilities/index.js +0 -8
- package/tslib/utilities/loading.js +0 -25
- package/tslib/utilities/logger.js +0 -92
- package/tslib/utilities/merge-stream.js +0 -34
- package/tslib/utilities/namespace.js +0 -12
- package/tslib/utilities/public-url.js +0 -31
- package/tslib/utilities/replacestream.js +0 -112
- package/tslib/utilities/typeof.js +0 -8
- package/tslib/utilities/utils.js +0 -38
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import BalmTask from './balm.js';
|
|
2
|
-
import { ASSET } from '../../config/constants.js';
|
|
3
|
-
class BalmStyleTask extends BalmTask {
|
|
4
|
-
constructor(name) {
|
|
5
|
-
super(name);
|
|
6
|
-
let extname;
|
|
7
|
-
switch (name) {
|
|
8
|
-
case 'sass':
|
|
9
|
-
extname = '{scss,sass}';
|
|
10
|
-
break;
|
|
11
|
-
case 'less':
|
|
12
|
-
extname = 'less';
|
|
13
|
-
break;
|
|
14
|
-
default:
|
|
15
|
-
extname = 'css';
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(BalmJS.config.styles.entry)) {
|
|
18
|
-
this.defaultInput = BalmJS.config.styles.entry.map(styleEntry => node.path.join(BalmJS.config.src.css, styleEntry));
|
|
19
|
-
} else {
|
|
20
|
-
if (BalmJS.config.styles.entry) {
|
|
21
|
-
this.defaultInput = node.path.join(BalmJS.config.src.css, BalmJS.config.styles.entry);
|
|
22
|
-
} else {
|
|
23
|
-
this.defaultInput = node.path.join(BalmJS.config.src.css, '**', `!(_*).${extname}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
this.defaultOutput = BalmJS.config.env.isMP ? node.path.join(BalmJS.config.dest.base, ASSET.mpDir, BalmJS.config.paths.target.css) : BalmJS.config.dest.css;
|
|
27
|
-
}
|
|
28
|
-
handleStyle(style, output, options) {
|
|
29
|
-
BalmJS.logger.debug(`${this.name} entry`, this.defaultInput, {
|
|
30
|
-
pre: true
|
|
31
|
-
});
|
|
32
|
-
const taskName = `${this.name} task`;
|
|
33
|
-
const shouldUseSourceMap = !(BalmJS.config.env.isProd || BalmJS.config.styles.minify);
|
|
34
|
-
let stream = gulp.src(this.input, Object.assign({
|
|
35
|
-
sourcemaps: shouldUseSourceMap,
|
|
36
|
-
allowEmpty: true
|
|
37
|
-
}, this.gulpSrcOptions)).pipe(BalmJS.plugins.plumber(function (error) {
|
|
38
|
-
// https://github.com/floatdrop/gulp-plumber/issues/30
|
|
39
|
-
BalmJS.logger.error(taskName, error.message);
|
|
40
|
-
// Must emit end event for any dependent streams to pick up on this. Destroying the stream
|
|
41
|
-
// ensures nothing else in that stream gets done, for example, if we're dealing with five
|
|
42
|
-
// files, after an error in one of them, any other won't carry on. Doing destroy without
|
|
43
|
-
// ending it first will not notify depending streams, tasks like `watch` will hang up.
|
|
44
|
-
this.emit('end');
|
|
45
|
-
this.destroy();
|
|
46
|
-
}));
|
|
47
|
-
switch (style) {
|
|
48
|
-
case 'sass':
|
|
49
|
-
stream = stream.pipe(node.isLegacySass ? BalmJS.plugins.legacySass(options) : BalmJS.plugins.sass(options));
|
|
50
|
-
break;
|
|
51
|
-
case 'less':
|
|
52
|
-
stream = stream.pipe(BalmJS.plugins.less(options));
|
|
53
|
-
break;
|
|
54
|
-
default:
|
|
55
|
-
}
|
|
56
|
-
return stream.pipe(BalmJS.plugins.postcss(BalmJS.plugins.postcssPlugins(style === 'postcss'))).pipe($.if(BalmJS.config.env.isMP, BalmJS.plugins.rename({
|
|
57
|
-
extname: '.wxss'
|
|
58
|
-
}))).pipe(gulp.dest(output, {
|
|
59
|
-
sourcemaps: shouldUseSourceMap
|
|
60
|
-
})).pipe(server.reload({
|
|
61
|
-
stream: true
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export default BalmStyleTask;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import BalmTask from './balm.js';
|
|
2
|
-
import BalmStyleTask from './balm_style.js';
|
|
3
|
-
BalmJS.BalmTask = BalmTask;
|
|
4
|
-
BalmJS.BalmStyleTask = BalmStyleTask;
|
|
5
|
-
BalmJS.tasks = new Map(); // Main tasks
|
|
6
|
-
BalmJS.recipes = []; // Sub tasks
|
|
7
|
-
BalmJS.recipeIndex = 0;
|
|
8
|
-
BalmJS.server = null;
|
|
9
|
-
BalmJS.watchFtpFile = '';
|
|
10
|
-
BalmJS.watching = false;
|
package/lib/tasks/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import './foundation/index.js';
|
|
2
|
-
import PRIVATE_TASKS from './private/index.js';
|
|
3
|
-
import PUBLIC_TASKS from './public/index.js';
|
|
4
|
-
import DefaultTask from './default.js';
|
|
5
|
-
import BalmHooks from '../hooks/index.js';
|
|
6
|
-
function registerTasks(recipe) {
|
|
7
|
-
const AwesomeTasks = BalmJS.utils.deepMerge(PRIVATE_TASKS, PUBLIC_TASKS);
|
|
8
|
-
|
|
9
|
-
// 1. Register balm tasks
|
|
10
|
-
const depsTasks = [];
|
|
11
|
-
const nonDepsTasks = [];
|
|
12
|
-
Object.values(AwesomeTasks).forEach(AwesomeTask => {
|
|
13
|
-
const awesomeTask = new AwesomeTask();
|
|
14
|
-
awesomeTask.deps ? depsTasks.push(awesomeTask) : nonDepsTasks.push(awesomeTask);
|
|
15
|
-
});
|
|
16
|
-
nonDepsTasks.forEach(task => {
|
|
17
|
-
const taskName = task.taskName;
|
|
18
|
-
const taskFunction = task.fn;
|
|
19
|
-
gulp.task(taskName, taskFunction);
|
|
20
|
-
BalmJS.tasks.set(task.name, task);
|
|
21
|
-
});
|
|
22
|
-
depsTasks.forEach(task => {
|
|
23
|
-
const taskName = task.taskName;
|
|
24
|
-
const taskFunction = task.deps.length ? gulp.series(...BalmJS.toNamespace(task.deps)) : callback => {
|
|
25
|
-
callback();
|
|
26
|
-
};
|
|
27
|
-
gulp.task(taskName, taskFunction);
|
|
28
|
-
BalmJS.tasks.set(task.name, task);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// 2. Register balm hooks
|
|
32
|
-
try {
|
|
33
|
-
recipe(new BalmHooks());
|
|
34
|
-
} catch (error) {
|
|
35
|
-
const {
|
|
36
|
-
message
|
|
37
|
-
} = error;
|
|
38
|
-
BalmJS.logger.error('balm hook', message);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// 3. Register balm default task
|
|
42
|
-
const defaultTask = new DefaultTask();
|
|
43
|
-
gulp.task(defaultTask.taskName, gulp.series(...defaultTask.startTask, ...defaultTask.mainTasks, ...defaultTask.subTasks, ...defaultTask.endTask));
|
|
44
|
-
|
|
45
|
-
// 4. Run
|
|
46
|
-
gulp.parallel('balm:default')();
|
|
47
|
-
}
|
|
48
|
-
export default registerTasks;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import gulpSize from 'gulp-size';
|
|
5
|
-
class BuildTask extends BalmJS.BalmTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('build');
|
|
8
|
-
_defineProperty(this, "fn", () => {
|
|
9
|
-
this.init();
|
|
10
|
-
return this.src.pipe(gulpSize({
|
|
11
|
-
title: this.name,
|
|
12
|
-
gzip: true
|
|
13
|
-
}));
|
|
14
|
-
});
|
|
15
|
-
this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.dest.base);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export default BuildTask;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import revAll from 'gulp-rev-all';
|
|
5
|
-
import { ASSETS_TYPES, CHUNK, ASSET } from '../../config/constants.js';
|
|
6
|
-
class CacheTask extends BalmJS.BalmTask {
|
|
7
|
-
constructor() {
|
|
8
|
-
super('cache');
|
|
9
|
-
_defineProperty(this, "fn", () => {
|
|
10
|
-
this.init();
|
|
11
|
-
this.gulpSrcOptions = {
|
|
12
|
-
base: this.output
|
|
13
|
-
};
|
|
14
|
-
return this.src.pipe(revAll.revision(BalmJS.config.assets.options)).pipe($.if(/\.html$/, BalmJS.file.setPublicPath())).pipe(gulp.dest(this.output)).pipe($.revDeleteOriginal({
|
|
15
|
-
exclude: /\.html$/
|
|
16
|
-
})).pipe(revAll.manifestFile()).pipe(gulp.dest(this.output));
|
|
17
|
-
});
|
|
18
|
-
const defaultIncludes = BalmJS.config.scripts.useCache ? ASSETS_TYPES.filter(assetType => assetType !== 'js').map(assetType => BalmJS.file.matchAllFiles(BalmJS.config.dest[assetType])) : ASSETS_TYPES.map(assetType => BalmJS.file.matchAllFiles(BalmJS.config.dest[assetType]));
|
|
19
|
-
const defaultExcludes = [node.path.join(`!${BalmJS.config.dest.js}`, CHUNK.dir, '*'), node.path.join(`!${BalmJS.config.dest.js}`, ASSET.dir, '*'), node.path.join(`!${BalmJS.config.dest.base}`, BalmJS.config.pwa.manifest)];
|
|
20
|
-
const customIncludes = BalmJS.config.assets.includes;
|
|
21
|
-
const customExcludes = BalmJS.config.assets.excludes.map(filename => {
|
|
22
|
-
return `!${filename}`;
|
|
23
|
-
});
|
|
24
|
-
this.defaultInput = [...defaultIncludes, ...defaultExcludes, ...(BalmJS.config.inFrontend ? [node.path.join(BalmJS.config.dest.base, '*.html')] : []), ...customIncludes, ...customExcludes];
|
|
25
|
-
this.defaultOutput = BalmJS.config.inFrontend ? BalmJS.config.dest.base : BalmJS.config.dest.static;
|
|
26
|
-
this.gulpSrcOptions = {
|
|
27
|
-
base: this.defaultOutput
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export default CacheTask;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
5
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
7
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
8
|
-
import { deleteAsync } from 'del';
|
|
9
|
-
import { ASSETS_TYPES } from '../../config/constants.js';
|
|
10
|
-
function unique(arr) {
|
|
11
|
-
const obj = {};
|
|
12
|
-
const result = [];
|
|
13
|
-
for (let i = 0, len = arr.length; i < len; i++) {
|
|
14
|
-
if (!obj[arr[i]]) {
|
|
15
|
-
obj[arr[i]] = true;
|
|
16
|
-
result.push(arr[i].replace(/\\/g, '/')); // NOTE: compatible with windows for `del@5.x`
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
var _getAssetsDir = /*#__PURE__*/new WeakMap();
|
|
22
|
-
class CleanTask extends BalmJS.BalmTask {
|
|
23
|
-
constructor() {
|
|
24
|
-
super('clean');
|
|
25
|
-
_classPrivateFieldInitSpec(this, _getAssetsDir, (rootKey = 'assets') => {
|
|
26
|
-
return unique(ASSETS_TYPES.map(assetType => BalmJS.config[rootKey][assetType]));
|
|
27
|
-
});
|
|
28
|
-
_defineProperty(this, "fn", async callback => {
|
|
29
|
-
const taskName = `${this.name} task`;
|
|
30
|
-
const directories = BalmJS.config.inFrontend ? this.dirInFrontend : this.dirInBackend;
|
|
31
|
-
if (BalmJS.config.env.isProd && !BalmJS.config.assets.root) {
|
|
32
|
-
BalmJS.logger.warn(taskName, 'Remote root path is empty');
|
|
33
|
-
}
|
|
34
|
-
BalmJS.logger.debug(taskName, {
|
|
35
|
-
directories
|
|
36
|
-
}, {
|
|
37
|
-
pre: true
|
|
38
|
-
});
|
|
39
|
-
const deletedPaths = await deleteAsync(directories, {
|
|
40
|
-
force: true
|
|
41
|
-
});
|
|
42
|
-
BalmJS.logger.warn(taskName, {
|
|
43
|
-
deletedPaths
|
|
44
|
-
}, {
|
|
45
|
-
pre: true
|
|
46
|
-
});
|
|
47
|
-
callback();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
get remoteRootDir() {
|
|
51
|
-
return BalmJS.config.assets.root.trim().length ? [BalmJS.config.assets.root] : [];
|
|
52
|
-
}
|
|
53
|
-
get remoteAppDir() {
|
|
54
|
-
return BalmJS.config.assets.subDir ? [BalmJS.config.assets.static] : _classPrivateFieldGet(_getAssetsDir, this).call(this);
|
|
55
|
-
}
|
|
56
|
-
get dirInFrontend() {
|
|
57
|
-
const isLocal = !node.path.isAbsolute(BalmJS.config.assets.root);
|
|
58
|
-
BalmJS.logger.info(`${this.name} task`, `'${BalmJS.config.assets.root}' is local directory: ${isLocal}`);
|
|
59
|
-
return BalmJS.config.env.isProd ? [BalmJS.file.absPath(BalmJS.config.roots.target), ...(isLocal ? this.remoteRootDir : this.remoteAppDir)] : [BalmJS.file.absPath(BalmJS.config.roots.tmp)];
|
|
60
|
-
}
|
|
61
|
-
get dirInBackend() {
|
|
62
|
-
const hasBuildDir = BalmJS.config.assets.cache && !!(BalmJS.config.assets.buildDir || BalmJS.config.assets.subDir);
|
|
63
|
-
const buildDirInProd = hasBuildDir ? [BalmJS.config.dest.static] : [];
|
|
64
|
-
const buildDirInDev = hasBuildDir ? [node.path.join(BalmJS.config.dest.static, BalmJS.config.assets.buildDir)] // NOTE: fix for `BalmJS.file.assetsSuffixPath` in development
|
|
65
|
-
: [];
|
|
66
|
-
return [...(BalmJS.config.env.isProd && hasBuildDir ? buildDirInProd : [...buildDirInDev, ..._classPrivateFieldGet(_getAssetsDir, this).call(this, 'dest')])];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export default CleanTask;
|
package/lib/tasks/private/end.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class EndTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('end');
|
|
7
|
-
_defineProperty(this, "fn", async callback => {
|
|
8
|
-
if (BalmJS.utils.isFunction(BalmJS.afterTask)) {
|
|
9
|
-
await BalmJS.afterTask();
|
|
10
|
-
}
|
|
11
|
-
this.time();
|
|
12
|
-
BalmJS.emitter.emit('exit');
|
|
13
|
-
callback();
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
time() {
|
|
17
|
-
const end = process.hrtime(BalmJS.start);
|
|
18
|
-
const timeInMs = Math.ceil((end[0] * 1000000000 + end[1]) / 1000000);
|
|
19
|
-
BalmJS.logger.info('execution time', `${timeInMs}ms`, {
|
|
20
|
-
logLevel: BalmJS.LogLevel.Error
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export default EndTask;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class ExtraTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('extra');
|
|
7
|
-
_defineProperty(this, "fn", () => {
|
|
8
|
-
this.init();
|
|
9
|
-
this.gulpSrcOptions = {
|
|
10
|
-
dot: true
|
|
11
|
-
};
|
|
12
|
-
return this.src.pipe(gulp.dest(this.output));
|
|
13
|
-
});
|
|
14
|
-
const includeGlobs = [];
|
|
15
|
-
if (BalmJS.config.extras.includes.length) {
|
|
16
|
-
for (const filename of BalmJS.config.extras.includes) {
|
|
17
|
-
includeGlobs.push(node.path.join(BalmJS.config.src.base, filename));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const excludeGlobs = [];
|
|
21
|
-
if (BalmJS.config.extras.excludes.length) {
|
|
22
|
-
for (const filename of BalmJS.config.extras.excludes) {
|
|
23
|
-
excludeGlobs.push(node.path.join(`!${BalmJS.config.src.base}`, filename));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const defaultGlobs = [node.path.join(BalmJS.config.src.base, '*.*'),
|
|
27
|
-
// All files but ignore all folders in the app root directory
|
|
28
|
-
node.path.join(`!${BalmJS.config.src.base}`, '*.html'), node.path.join(`!${BalmJS.config.src.base}`, BalmJS.config.pwa.manifest), ...includeGlobs,
|
|
29
|
-
// e.g. CNAME
|
|
30
|
-
...excludeGlobs];
|
|
31
|
-
this.defaultInput = defaultGlobs;
|
|
32
|
-
this.defaultOutput = BalmJS.config.dest.base;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default ExtraTask;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class FontTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('font');
|
|
7
|
-
_defineProperty(this, "fn", () => {
|
|
8
|
-
this.init();
|
|
9
|
-
return this.src.pipe(gulp.dest(this.output));
|
|
10
|
-
});
|
|
11
|
-
this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.src.font, '*.{eot,svg,ttf,woff,woff2}');
|
|
12
|
-
this.defaultOutput = BalmJS.config.dest.font;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default FontTask;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import { getDefaultImagePlugins } from '../../plugins/imagemin.js';
|
|
5
|
-
class ImageTask extends BalmJS.BalmTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('image');
|
|
8
|
-
_defineProperty(this, "fn", () => {
|
|
9
|
-
this.init();
|
|
10
|
-
const balmImage = () => {
|
|
11
|
-
return gulp.src(BalmJS.file.absPaths(this.input), {
|
|
12
|
-
since: gulp.lastRun(balmImage),
|
|
13
|
-
encoding: false
|
|
14
|
-
}).pipe(BalmJS.plugins.plumber(error => {
|
|
15
|
-
BalmJS.logger.error(`${this.name} task`, error);
|
|
16
|
-
})).pipe(BalmJS.plugins.imagemin(this.plugins)).pipe(gulp.dest(this.output));
|
|
17
|
-
};
|
|
18
|
-
return balmImage();
|
|
19
|
-
});
|
|
20
|
-
const excludeGlobs = [];
|
|
21
|
-
for (const imageFolder of BalmJS.config.styles.sprites) {
|
|
22
|
-
excludeGlobs.push(node.path.join(`!${BalmJS.config.src.img}`, imageFolder));
|
|
23
|
-
excludeGlobs.push(node.path.join(`!${BalmJS.config.src.img}`, imageFolder, '*.png'));
|
|
24
|
-
}
|
|
25
|
-
this.defaultInput = [BalmJS.file.matchAllFiles(BalmJS.config.src.img), ...excludeGlobs];
|
|
26
|
-
this.defaultOutput = BalmJS.config.dest.img;
|
|
27
|
-
if (BalmJS.utils.isArray(BalmJS.config.images.plugins)) {
|
|
28
|
-
this.plugins = BalmJS.config.images.plugins; // Using custom imagemin plugins
|
|
29
|
-
} else {
|
|
30
|
-
const defaultPlugins = Object.assign(getDefaultImagePlugins(), BalmJS.config.images.plugins);
|
|
31
|
-
const enablePlugins = Object.keys(defaultPlugins).filter(key => defaultPlugins[key]);
|
|
32
|
-
this.plugins = enablePlugins.map(key => defaultPlugins[key]);
|
|
33
|
-
BalmJS.logger.debug(`${this.name} task - plugins`, enablePlugins);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export default ImageTask;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import StartTask from './start.js';
|
|
2
|
-
import CleanTask from './clean.js';
|
|
3
|
-
import SpriteTask from './sprite.js';
|
|
4
|
-
import StyleTask from './style.js';
|
|
5
|
-
import LintTask from './lint.js';
|
|
6
|
-
import ScriptTask from './script.js';
|
|
7
|
-
import ImageTask from './image.js';
|
|
8
|
-
import FontTask from './font.js';
|
|
9
|
-
import MediaTask from './media.js';
|
|
10
|
-
import ModernizrTask from './modernizr.js';
|
|
11
|
-
import ExtraTask from './extra.js';
|
|
12
|
-
import BuildTask from './build.js';
|
|
13
|
-
import CacheTask from './cache.js';
|
|
14
|
-
import WorkboxSwTask from './workbox-sw.js';
|
|
15
|
-
import PwaCacheTask from './pwa-cache.js';
|
|
16
|
-
import EndTask from './end.js';
|
|
17
|
-
export default {
|
|
18
|
-
StartTask,
|
|
19
|
-
CleanTask,
|
|
20
|
-
SpriteTask,
|
|
21
|
-
StyleTask,
|
|
22
|
-
LintTask,
|
|
23
|
-
ScriptTask,
|
|
24
|
-
ImageTask,
|
|
25
|
-
FontTask,
|
|
26
|
-
MediaTask,
|
|
27
|
-
ModernizrTask,
|
|
28
|
-
ExtraTask,
|
|
29
|
-
BuildTask,
|
|
30
|
-
CacheTask,
|
|
31
|
-
WorkboxSwTask,
|
|
32
|
-
PwaCacheTask,
|
|
33
|
-
EndTask
|
|
34
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class LintTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('lint');
|
|
7
|
-
_defineProperty(this, "fn", () => {
|
|
8
|
-
this.init();
|
|
9
|
-
return this.src.pipe($.eslint({
|
|
10
|
-
fix: true
|
|
11
|
-
})).pipe(server.reload({
|
|
12
|
-
stream: true,
|
|
13
|
-
once: true
|
|
14
|
-
})).pipe($.eslint.format()).pipe($.if(!server.active, $.eslint.failAfterError())).pipe(gulp.dest(this.output));
|
|
15
|
-
});
|
|
16
|
-
this.defaultOutput = BalmJS.config.src.js;
|
|
17
|
-
this.defaultInput = BalmJS.file.matchAllFiles(this.defaultOutput, '*.js');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export default LintTask;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
class MediaTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('media');
|
|
7
|
-
_defineProperty(this, "fn", () => {
|
|
8
|
-
this.init();
|
|
9
|
-
return this.src.pipe(gulp.dest(this.output));
|
|
10
|
-
});
|
|
11
|
-
this.defaultInput = BalmJS.file.matchAllFiles(BalmJS.config.src.media);
|
|
12
|
-
this.defaultOutput = BalmJS.config.dest.media;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default MediaTask;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
5
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
7
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
8
|
-
import { build } from 'modernizr';
|
|
9
|
-
var _readConfig = /*#__PURE__*/new WeakMap();
|
|
10
|
-
var _createDir = /*#__PURE__*/new WeakMap();
|
|
11
|
-
var _generateScript = /*#__PURE__*/new WeakMap();
|
|
12
|
-
class ModernizrTask extends BalmJS.BalmTask {
|
|
13
|
-
constructor() {
|
|
14
|
-
super('modernizr');
|
|
15
|
-
_classPrivateFieldInitSpec(this, _readConfig, () => {
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
node.fs.readFile(this.input, 'utf8', (err, data) => {
|
|
18
|
-
if (err) reject(err);
|
|
19
|
-
resolve(JSON.parse(data));
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
_classPrivateFieldInitSpec(this, _createDir, () => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
node.fs.mkdir(BalmJS.file.absPath(BalmJS.config.dest.js), {
|
|
26
|
-
recursive: true
|
|
27
|
-
}, err => {
|
|
28
|
-
if (err) reject(err);
|
|
29
|
-
resolve();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
_classPrivateFieldInitSpec(this, _generateScript, config => {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
build(config, content => {
|
|
36
|
-
node.fs.writeFile(this.output, content, err => {
|
|
37
|
-
if (err) reject(err);
|
|
38
|
-
resolve(content);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
_defineProperty(this, "fn", async callback => {
|
|
44
|
-
this.init();
|
|
45
|
-
if (node.fs.existsSync(this.input)) {
|
|
46
|
-
const [config] = await Promise.all([_classPrivateFieldGet(_readConfig, this).call(this), _classPrivateFieldGet(_createDir, this).call(this)]);
|
|
47
|
-
await _classPrivateFieldGet(_generateScript, this).call(this, config);
|
|
48
|
-
} else {
|
|
49
|
-
BalmJS.logger.warn(`${this.name} task`, `The '${this.input}' does not exist`, {
|
|
50
|
-
logLevel: BalmJS.LogLevel.Info
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
callback();
|
|
54
|
-
});
|
|
55
|
-
this.defaultInput = `${this.name}.json`;
|
|
56
|
-
this.defaultOutput = node.path.join(BalmJS.config.dest.js, `${this.name}.js`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export default ModernizrTask;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import { deleteAsync } from 'del';
|
|
5
|
-
class PwaCacheTask extends BalmJS.BalmTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('pwa-cache');
|
|
8
|
-
_defineProperty(this, "fn", () => {
|
|
9
|
-
this.init();
|
|
10
|
-
const swDest = typeof this.input === 'string' && this.input ? BalmJS.file.absPath(this.input) : '';
|
|
11
|
-
if (!swDest || !node.fs.existsSync(swDest)) {
|
|
12
|
-
return Promise.resolve();
|
|
13
|
-
}
|
|
14
|
-
const newVersion = BalmJS.config.pwa.version || Date.now().toString();
|
|
15
|
-
BalmJS.logger.info('pwa - version', newVersion);
|
|
16
|
-
const stream = this.src.pipe(BalmJS.plugins.replace('{{ version }}', newVersion)).pipe($.if(BalmJS.config.env.isProd, BalmJS.plugins.jsmin(BalmJS.config.scripts.minifyOptions))).pipe(gulp.dest(this.output));
|
|
17
|
-
this.clear();
|
|
18
|
-
return stream;
|
|
19
|
-
});
|
|
20
|
-
this.defaultOutput = BalmJS.config.dest.base;
|
|
21
|
-
this.defaultInput = node.path.join(this.defaultOutput, BalmJS.config.pwa.swDestFilename);
|
|
22
|
-
}
|
|
23
|
-
clear() {
|
|
24
|
-
if (BalmJS.config.pwa.swSrcFilename !== BalmJS.config.pwa.swDestFilename) {
|
|
25
|
-
const swOrigin = BalmJS.file.absPath(node.path.join(BalmJS.config.dest.base, BalmJS.config.pwa.swSrcFilename));
|
|
26
|
-
deleteAsync(swOrigin, {
|
|
27
|
-
force: true
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export default PwaCacheTask;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
2
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
4
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
5
|
-
import mergeStream from '../../utilities/merge-stream.js';
|
|
6
|
-
var _tasks = /*#__PURE__*/new WeakMap();
|
|
7
|
-
var _getParams = /*#__PURE__*/new WeakMap();
|
|
8
|
-
class SpriteTask extends BalmJS.BalmTask {
|
|
9
|
-
constructor() {
|
|
10
|
-
super('sprite');
|
|
11
|
-
_classPrivateFieldInitSpec(this, _tasks, []);
|
|
12
|
-
_classPrivateFieldInitSpec(this, _getParams, (spriteItem, spriteOptions) => {
|
|
13
|
-
const stylesConfig = Object.assign(spriteOptions, BalmJS.config.styles);
|
|
14
|
-
const spriteName = `${spriteItem.folderName}-${this.name}s`;
|
|
15
|
-
const imageTarget = stylesConfig.imageTarget || BalmJS.config.paths.target.img;
|
|
16
|
-
let defaultParams = Object.assign({
|
|
17
|
-
padding: 1
|
|
18
|
-
}, {
|
|
19
|
-
imgName: `${spriteName}.png`,
|
|
20
|
-
// E.g. 'awesome-sprites.png'
|
|
21
|
-
cssName: `_${spriteItem.folderName}.${stylesConfig.extname}`,
|
|
22
|
-
// E.g. "_awesome.{css,sass,scss,less}"
|
|
23
|
-
imgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}.png`,
|
|
24
|
-
// E.g. "../img/awesome-sprites.png"
|
|
25
|
-
cssVarMap: sprite => {
|
|
26
|
-
sprite.name = `${spriteItem.folderName}-${sprite.name}`; // E.g. "awesome-icon-name"
|
|
27
|
-
},
|
|
28
|
-
cssSpritesheetName: `${spriteItem.folderName}-spritesheet`,
|
|
29
|
-
// E.g. "awesome-spritesheet"
|
|
30
|
-
cssOpts: {
|
|
31
|
-
cssSelector: sprite => `.${sprite.name}` // className in css file: '.icon-awesome'
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
if (stylesConfig.spriteRetina) {
|
|
35
|
-
defaultParams = Object.assign(defaultParams, {
|
|
36
|
-
retinaSrcFilter: `${spriteItem.retinaSrc}`,
|
|
37
|
-
retinaImgName: `${spriteName}@2x.png`,
|
|
38
|
-
// E.g. 'awesome-sprites@2x.png'
|
|
39
|
-
retinaImgPath: `${stylesConfig.imageBasePath}${imageTarget}/${spriteName}@2x.png`,
|
|
40
|
-
// E.g. "../img/awesome-sprites@2x.png"
|
|
41
|
-
cssVarMap: sprite => {
|
|
42
|
-
sprite.name = `${spriteItem.folderName}-${sprite.name}`; // E.g. "awesome-icon-name"
|
|
43
|
-
},
|
|
44
|
-
cssRetinaSpritesheetName: `${spriteItem.folderName}-spritesheet-2x`,
|
|
45
|
-
// E.g. "awesome-spritesheet-2x"
|
|
46
|
-
cssRetinaGroupsName: `${spriteItem.folderName}-retina-groups` // E.g. "awesome-retina-groups"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return Object.assign(defaultParams, stylesConfig.spriteParams);
|
|
50
|
-
});
|
|
51
|
-
this.defaultInput = BalmJS.config.styles.sprites;
|
|
52
|
-
this.defaultOutput = BalmJS.config.dest.img;
|
|
53
|
-
if (this.defaultInput.length) {
|
|
54
|
-
this.init();
|
|
55
|
-
this.collect();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
collect(spriteOptions = {}) {
|
|
59
|
-
const spriteList = [];
|
|
60
|
-
for (const spriteName of this.input) {
|
|
61
|
-
spriteList.push({
|
|
62
|
-
src: `${BalmJS.config.src.img}/${spriteName}/*.png`,
|
|
63
|
-
retinaSrc: `${BalmJS.config.src.img}/${spriteName}/*@2x.png`,
|
|
64
|
-
folderName: spriteName
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
for (let key = 0, len = spriteList.length; key < len; key++) {
|
|
68
|
-
const spriteItem = spriteList[key];
|
|
69
|
-
const spriteTaskName = `${this.name}:${spriteItem.folderName}`; // E.g. 'sprite:awesome'
|
|
70
|
-
const spriteConfig = {
|
|
71
|
-
input: BalmJS.file.absPath(spriteItem.src),
|
|
72
|
-
imgOutput: BalmJS.file.absPath(this.output),
|
|
73
|
-
cssOutput: BalmJS.file.absPath(`${BalmJS.config.src.css}/${this.name}s`) // E.g. 'path/to/css/sprites'
|
|
74
|
-
};
|
|
75
|
-
BalmJS.logger.debug(`${this.name} task`, spriteConfig, {
|
|
76
|
-
pre: true
|
|
77
|
-
});
|
|
78
|
-
spriteConfig.params = _classPrivateFieldGet(_getParams, this).call(this, spriteItem, spriteOptions);
|
|
79
|
-
gulp.task(BalmJS.toNamespace(spriteTaskName), () => {
|
|
80
|
-
const spriteData = gulp.src(spriteConfig.input, {
|
|
81
|
-
encoding: false
|
|
82
|
-
}).pipe(BalmJS.plugins.plumber(error => {
|
|
83
|
-
BalmJS.logger.error(`${this.name} task`, error.message);
|
|
84
|
-
})).pipe($.spritesmith(spriteConfig.params));
|
|
85
|
-
const imgStream = spriteData.img.pipe(gulp.dest(spriteConfig.imgOutput));
|
|
86
|
-
const cssStream = spriteData.css.pipe(gulp.dest(spriteConfig.cssOutput));
|
|
87
|
-
return mergeStream(imgStream, cssStream);
|
|
88
|
-
});
|
|
89
|
-
_classPrivateFieldGet(_tasks, this).push(spriteTaskName);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
recipe(input, output, spriteOptions = {}) {
|
|
93
|
-
if (input.length) {
|
|
94
|
-
if (output && !spriteOptions.imageTarget) {
|
|
95
|
-
spriteOptions.imageTarget = output.split('/').pop();
|
|
96
|
-
}
|
|
97
|
-
this.init(input, output);
|
|
98
|
-
this.collect(spriteOptions);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
get deps() {
|
|
102
|
-
return _classPrivateFieldGet(_tasks, this);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
export default SpriteTask;
|