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,16 +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 StartTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('start');
|
|
7
|
-
_defineProperty(this, "fn", async callback => {
|
|
8
|
-
BalmJS.start = process.hrtime();
|
|
9
|
-
if (BalmJS.utils.isFunction(BalmJS.beforeTask)) {
|
|
10
|
-
await BalmJS.beforeTask();
|
|
11
|
-
}
|
|
12
|
-
callback();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default StartTask;
|
|
@@ -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 WorkboxSwTask extends BalmJS.BalmTask {
|
|
5
|
-
constructor() {
|
|
6
|
-
super('workbox-sw');
|
|
7
|
-
_defineProperty(this, "fn", () => {
|
|
8
|
-
this.init();
|
|
9
|
-
return this.src.pipe(gulp.dest(this.output));
|
|
10
|
-
});
|
|
11
|
-
this.defaultInput = [BalmJS.config.pwa.workboxSw, `${BalmJS.config.pwa.workboxSw}.map`];
|
|
12
|
-
this.defaultOutput = BalmJS.config.dest.base;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default WorkboxSwTask;
|
package/lib/tasks/public/copy.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class CopyTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('copy');
|
|
4
|
-
}
|
|
5
|
-
recipe(input, output, options = {}) {
|
|
6
|
-
const balmCopy = () => {
|
|
7
|
-
this.init(input, output, options);
|
|
8
|
-
return this.src.pipe(BalmJS.plugins.rename(this.customOptions)).pipe(gulp.dest(this.output));
|
|
9
|
-
};
|
|
10
|
-
return balmCopy;
|
|
11
|
-
}
|
|
12
|
-
fn(callback) {
|
|
13
|
-
callback();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default CopyTask;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import esbuild from '../../bundler/esbuild/index.js';
|
|
2
|
-
class EsbuildTask extends BalmJS.BalmTask {
|
|
3
|
-
constructor() {
|
|
4
|
-
super('esbuild');
|
|
5
|
-
this.defaultOutput = BalmJS.config.dest.js;
|
|
6
|
-
}
|
|
7
|
-
recipe(input, output, customOptions = {}) {
|
|
8
|
-
const balmBundler = callback => {
|
|
9
|
-
this.init(input || BalmJS.config.scripts.entry, output);
|
|
10
|
-
esbuild(this.input || BalmJS.file.defaultEntry, this.output, customOptions, callback);
|
|
11
|
-
};
|
|
12
|
-
return balmBundler;
|
|
13
|
-
}
|
|
14
|
-
get fn() {
|
|
15
|
-
return this.recipe();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export default EsbuildTask;
|
package/lib/tasks/public/ftp.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
class FtpTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('ftp');
|
|
4
|
-
}
|
|
5
|
-
get options() {
|
|
6
|
-
return Object.assign({}, BalmJS.config.ftp.options, this.customOptions);
|
|
7
|
-
}
|
|
8
|
-
recipe(localFiles, options = {}) {
|
|
9
|
-
const balmFtp = () => {
|
|
10
|
-
const taskName = `${this.name} task`;
|
|
11
|
-
const input = localFiles || BalmJS.watchFtpFile;
|
|
12
|
-
if (input) {
|
|
13
|
-
this.init(input, null, options);
|
|
14
|
-
if (!options.src) {
|
|
15
|
-
this.gulpSrcOptions = {
|
|
16
|
-
base: '.'
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
let stream = this.src;
|
|
20
|
-
try {
|
|
21
|
-
stream = stream.pipe(BalmJS.plugins.sftp(this.options));
|
|
22
|
-
} catch (error) {
|
|
23
|
-
const {
|
|
24
|
-
message
|
|
25
|
-
} = error;
|
|
26
|
-
BalmJS.logger.error(taskName, message);
|
|
27
|
-
}
|
|
28
|
-
return stream;
|
|
29
|
-
} else {
|
|
30
|
-
BalmJS.logger.warn(taskName, 'Invalid local files');
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
return balmFtp;
|
|
34
|
-
}
|
|
35
|
-
get fn() {
|
|
36
|
-
return this.recipe();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default FtpTask;
|
package/lib/tasks/public/html.js
DELETED
|
@@ -1,65 +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 { PUBLIC_URL } from '../../config/constants.js';
|
|
6
|
-
var _updateAssetsPath = /*#__PURE__*/new WeakMap();
|
|
7
|
-
var _hasSourcePath = /*#__PURE__*/new WeakMap();
|
|
8
|
-
class HtmlTask extends BalmJS.BalmTask {
|
|
9
|
-
constructor() {
|
|
10
|
-
super('html');
|
|
11
|
-
_classPrivateFieldInitSpec(this, _updateAssetsPath, type => {
|
|
12
|
-
const isManifest = type === 'manifest';
|
|
13
|
-
const assetsType = isManifest ? 'img' : type;
|
|
14
|
-
const from = BalmJS.config.paths.source[assetsType];
|
|
15
|
-
const to = BalmJS.file.assetsPath(BalmJS.config.paths.target[assetsType]);
|
|
16
|
-
const assetsPathSrc = new RegExp(isManifest ? `/?${from}` : `${PUBLIC_URL}/${from}`, 'g');
|
|
17
|
-
const assetsPathDest = `${PUBLIC_URL}/${to}`;
|
|
18
|
-
BalmJS.logger.debug(`${this.name} task - assets path`, {
|
|
19
|
-
regex: assetsPathSrc,
|
|
20
|
-
replacement: assetsPathDest
|
|
21
|
-
}, {
|
|
22
|
-
pre: true
|
|
23
|
-
});
|
|
24
|
-
return BalmJS.plugins.replace(assetsPathSrc, assetsPathDest);
|
|
25
|
-
});
|
|
26
|
-
_classPrivateFieldInitSpec(this, _hasSourcePath, type => {
|
|
27
|
-
return !!BalmJS.config.paths.source[type];
|
|
28
|
-
});
|
|
29
|
-
this.defaultInput = [node.path.join(BalmJS.file.templateBasePath, '*.html'), node.path.join(BalmJS.file.templateBasePath, BalmJS.config.pwa.manifest)];
|
|
30
|
-
this.defaultOutput = BalmJS.config.dest.base;
|
|
31
|
-
}
|
|
32
|
-
recipe(input, output) {
|
|
33
|
-
const balmHtml = () => {
|
|
34
|
-
this.init(input, output);
|
|
35
|
-
let stream = this.src;
|
|
36
|
-
if (BalmJS.config.env.isProd) {
|
|
37
|
-
stream = stream.pipe($.useref({
|
|
38
|
-
base: BalmJS.config.workspace,
|
|
39
|
-
searchPath: [BalmJS.config.roots.tmp, BalmJS.config.roots.source, '.']
|
|
40
|
-
})).pipe($.if(/\.html$/, BalmJS.plugins.htmlmin(BalmJS.config.html.options)));
|
|
41
|
-
['css', 'js', 'img', 'media', 'manifest'].forEach(type => {
|
|
42
|
-
const canUpdate = type === 'manifest' ? BalmJS.config.pwa.enabled : _classPrivateFieldGet(_hasSourcePath, this).call(this, type);
|
|
43
|
-
if (canUpdate) {
|
|
44
|
-
stream = stream.pipe(_classPrivateFieldGet(_updateAssetsPath, this).call(this, type));
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
stream = BalmJS.config.assets.cache ? stream.pipe($.if(BalmJS.config.pwa.manifest, BalmJS.file.setPublicPath())) : stream.pipe(BalmJS.file.setPublicPath());
|
|
48
|
-
} else {
|
|
49
|
-
['css', 'js', 'img', 'media'].forEach((type, index) => {
|
|
50
|
-
const canUpdate = index > 1 ? _classPrivateFieldGet(_hasSourcePath, this).call(this, type) && !BalmJS.config.inFrontend : _classPrivateFieldGet(_hasSourcePath, this).call(this, type);
|
|
51
|
-
if (canUpdate) {
|
|
52
|
-
stream = stream.pipe(_classPrivateFieldGet(_updateAssetsPath, this).call(this, type));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
stream = stream.pipe(BalmJS.file.setPublicPath());
|
|
56
|
-
}
|
|
57
|
-
return stream.pipe(gulp.dest(this.output));
|
|
58
|
-
};
|
|
59
|
-
return balmHtml;
|
|
60
|
-
}
|
|
61
|
-
get fn() {
|
|
62
|
-
return this.recipe();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export default HtmlTask;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import SassTask from './sass.js';
|
|
2
|
-
import LessTask from './less.js';
|
|
3
|
-
import PostcssTask from './postcss.js';
|
|
4
|
-
import UrlTask from './url.js';
|
|
5
|
-
import WebpackTask from './webpack.js';
|
|
6
|
-
import EsbuildTask from './esbuild.js';
|
|
7
|
-
import RollupTask from './rollup.js';
|
|
8
|
-
import JsminTask from './jsmin.js';
|
|
9
|
-
import HtmlTask from './html.js';
|
|
10
|
-
import CopyTask from './copy.js';
|
|
11
|
-
import RemoveTask from './remove.js';
|
|
12
|
-
import ReplaceTask from './replace.js';
|
|
13
|
-
import VersionTask from './version.js';
|
|
14
|
-
import ServerTask from './server.js';
|
|
15
|
-
import PublishTask from './publish.js';
|
|
16
|
-
import ZipTask from './zip.js';
|
|
17
|
-
import FtpTask from './ftp.js';
|
|
18
|
-
import PwaTask from './pwa.js';
|
|
19
|
-
export default {
|
|
20
|
-
SassTask,
|
|
21
|
-
LessTask,
|
|
22
|
-
PostcssTask,
|
|
23
|
-
UrlTask,
|
|
24
|
-
WebpackTask,
|
|
25
|
-
EsbuildTask,
|
|
26
|
-
RollupTask,
|
|
27
|
-
JsminTask,
|
|
28
|
-
HtmlTask,
|
|
29
|
-
CopyTask,
|
|
30
|
-
RemoveTask,
|
|
31
|
-
ReplaceTask,
|
|
32
|
-
VersionTask,
|
|
33
|
-
ServerTask,
|
|
34
|
-
PublishTask,
|
|
35
|
-
ZipTask,
|
|
36
|
-
FtpTask,
|
|
37
|
-
PwaTask
|
|
38
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class JsminTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('jsmin');
|
|
4
|
-
}
|
|
5
|
-
get options() {
|
|
6
|
-
const defaultOptions = Object.assign({}, BalmJS.config.scripts.minifyOptions);
|
|
7
|
-
return BalmJS.utils.deepMerge(defaultOptions, this.customOptions);
|
|
8
|
-
}
|
|
9
|
-
recipe(input, output, options = {}) {
|
|
10
|
-
const balmJsmin = () => {
|
|
11
|
-
this.init(input, output, options);
|
|
12
|
-
const renameOptions = options.rename || {
|
|
13
|
-
suffix: '.min'
|
|
14
|
-
};
|
|
15
|
-
return this.src.pipe(BalmJS.plugins.jsmin(this.options)).pipe(BalmJS.plugins.rename(renameOptions)).pipe(gulp.dest(this.output));
|
|
16
|
-
};
|
|
17
|
-
return balmJsmin;
|
|
18
|
-
}
|
|
19
|
-
fn(callback) {
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export default JsminTask;
|
package/lib/tasks/public/less.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class LessTask extends BalmJS.BalmStyleTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('less');
|
|
4
|
-
}
|
|
5
|
-
get options() {
|
|
6
|
-
return Object.assign({
|
|
7
|
-
paths: BalmJS.file.stylePaths
|
|
8
|
-
}, BalmJS.config.styles.lessOptions, this.customOptions);
|
|
9
|
-
}
|
|
10
|
-
recipe(input, output, options = {}) {
|
|
11
|
-
const balmLess = () => {
|
|
12
|
-
this.init(input, output, options);
|
|
13
|
-
return this.handleStyle(this.name, this.output, this.options);
|
|
14
|
-
};
|
|
15
|
-
return balmLess;
|
|
16
|
-
}
|
|
17
|
-
get fn() {
|
|
18
|
-
return this.recipe();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export default LessTask;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class PostcssTask extends BalmJS.BalmStyleTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('postcss');
|
|
4
|
-
}
|
|
5
|
-
recipe(input, output) {
|
|
6
|
-
const balmPostcss = () => {
|
|
7
|
-
this.init(input, output);
|
|
8
|
-
return this.handleStyle(this.name, this.output);
|
|
9
|
-
};
|
|
10
|
-
return balmPostcss;
|
|
11
|
-
}
|
|
12
|
-
get fn() {
|
|
13
|
-
return this.recipe();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default PostcssTask;
|
|
@@ -1,51 +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 _release = /*#__PURE__*/new WeakMap();
|
|
7
|
-
class PublishTask extends BalmJS.BalmTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('publish');
|
|
10
|
-
_classPrivateFieldInitSpec(this, _release, (input, output, renameOptions = {}) => {
|
|
11
|
-
let srcPath;
|
|
12
|
-
let destPath;
|
|
13
|
-
if (input && output) {
|
|
14
|
-
srcPath = BalmJS.file.absPaths(node.path.join(BalmJS.config.dest.base, input));
|
|
15
|
-
destPath = BalmJS.file.absPath(node.path.join(BalmJS.config.assets.root, output));
|
|
16
|
-
} else {
|
|
17
|
-
this.init();
|
|
18
|
-
srcPath = this.input;
|
|
19
|
-
destPath = this.output;
|
|
20
|
-
}
|
|
21
|
-
return gulp.src(srcPath, {
|
|
22
|
-
allowEmpty: true
|
|
23
|
-
}).pipe($.if(!BalmJS.utils.isArray(srcPath), BalmJS.plugins.rename(renameOptions))).pipe(gulp.dest(destPath));
|
|
24
|
-
});
|
|
25
|
-
this.defaultInput = [BalmJS.file.matchAllFiles(BalmJS.config.dest.static),
|
|
26
|
-
// Assets
|
|
27
|
-
node.path.join(`!${BalmJS.config.dest.base}`, '*.*') // HTML
|
|
28
|
-
];
|
|
29
|
-
this.defaultOutput = BalmJS.config.assets.static; // Remote dir
|
|
30
|
-
}
|
|
31
|
-
recipe(input, output, renameOptions) {
|
|
32
|
-
const balmPublish = callback => {
|
|
33
|
-
if (BalmJS.config.env.isProd) {
|
|
34
|
-
if (BalmJS.utils.isArray(input)) {
|
|
35
|
-
const tasks = input.map(template => _classPrivateFieldGet(_release, this).call(this, template.input, template.output, template.renameOptions));
|
|
36
|
-
return mergeStream(...tasks);
|
|
37
|
-
} else {
|
|
38
|
-
return _classPrivateFieldGet(_release, this).call(this, input, output, renameOptions);
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
BalmJS.logger.warn(`${this.name} task`, '`mix.publish()` is only supported for production');
|
|
42
|
-
callback();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
return balmPublish;
|
|
46
|
-
}
|
|
47
|
-
fn(callback) {
|
|
48
|
-
callback();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export default PublishTask;
|
package/lib/tasks/public/pwa.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { generateSW, injectManifest } from 'workbox-build';
|
|
2
|
-
class PwaTask extends BalmJS.BalmTask {
|
|
3
|
-
constructor() {
|
|
4
|
-
super('pwa');
|
|
5
|
-
}
|
|
6
|
-
setIgnores(options) {
|
|
7
|
-
const defaultIgnores = [BalmJS.config.pwa.swSrcFilename];
|
|
8
|
-
if (options.globIgnores) {
|
|
9
|
-
options.globIgnores = options.globIgnores.concat(defaultIgnores);
|
|
10
|
-
} else {
|
|
11
|
-
options.globIgnores = defaultIgnores;
|
|
12
|
-
}
|
|
13
|
-
return options;
|
|
14
|
-
}
|
|
15
|
-
recipe(customMode, customOptions = {}) {
|
|
16
|
-
const balmPwa = async callback => {
|
|
17
|
-
const mode = customMode || BalmJS.config.pwa.mode;
|
|
18
|
-
let options = {};
|
|
19
|
-
const globDirectory = BalmJS.config.dest.base;
|
|
20
|
-
const swDest = BalmJS.file.absPath(`${globDirectory}/${BalmJS.config.pwa.swDestFilename}`);
|
|
21
|
-
const swSrc = BalmJS.file.absPath(`${BalmJS.config.src.base}/${BalmJS.config.pwa.swSrcFilename}`);
|
|
22
|
-
let valid = true;
|
|
23
|
-
switch (mode) {
|
|
24
|
-
// For basic
|
|
25
|
-
case 'generateSW':
|
|
26
|
-
options = Object.assign({
|
|
27
|
-
globDirectory,
|
|
28
|
-
swDest
|
|
29
|
-
}, BalmJS.config.pwa.options, customOptions);
|
|
30
|
-
break;
|
|
31
|
-
// For advanced
|
|
32
|
-
case 'injectManifest':
|
|
33
|
-
options = Object.assign({
|
|
34
|
-
globDirectory,
|
|
35
|
-
swDest,
|
|
36
|
-
swSrc
|
|
37
|
-
}, BalmJS.config.pwa.options, customOptions);
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
valid = false;
|
|
41
|
-
}
|
|
42
|
-
if (valid) {
|
|
43
|
-
options = this.setIgnores(options);
|
|
44
|
-
BalmJS.logger.debug(`pwa - ${mode}`, options, {
|
|
45
|
-
pre: true
|
|
46
|
-
});
|
|
47
|
-
const workboxBuild = mode === 'generateSW' ? generateSW(options) : injectManifest(options);
|
|
48
|
-
try {
|
|
49
|
-
const {
|
|
50
|
-
count,
|
|
51
|
-
size
|
|
52
|
-
} = await workboxBuild;
|
|
53
|
-
BalmJS.logger.info(`pwa - ${mode}`, `Generated '${swDest}', which will precache ${count} files, totaling ${size} bytes`);
|
|
54
|
-
await new Promise(resolve => {
|
|
55
|
-
const pwaCacheTask = BalmJS.tasks.get('pwa-cache');
|
|
56
|
-
if (pwaCacheTask) {
|
|
57
|
-
const stream = pwaCacheTask.fn();
|
|
58
|
-
if (stream && typeof stream.on === 'function') {
|
|
59
|
-
stream.on('finish', resolve).on('error', () => resolve());
|
|
60
|
-
} else if (stream && typeof stream.then === 'function') {
|
|
61
|
-
stream.then(resolve, resolve);
|
|
62
|
-
} else {
|
|
63
|
-
resolve();
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
resolve();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
} catch (err) {
|
|
70
|
-
BalmJS.logger.warn(`pwa - ${mode}`, `Service worker generation failed: ${err}`);
|
|
71
|
-
}
|
|
72
|
-
callback();
|
|
73
|
-
} else {
|
|
74
|
-
BalmJS.logger.warn('pwa task', 'Invalid PWA mode');
|
|
75
|
-
callback();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return balmPwa;
|
|
79
|
-
}
|
|
80
|
-
get fn() {
|
|
81
|
-
return this.recipe();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export default PwaTask;
|
|
@@ -1,46 +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 { deleteAsync } from 'del';
|
|
6
|
-
var _getFiles = /*#__PURE__*/new WeakMap();
|
|
7
|
-
class RemoveTask extends BalmJS.BalmTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('remove');
|
|
10
|
-
_classPrivateFieldInitSpec(this, _getFiles, input => {
|
|
11
|
-
let files = BalmJS.file.absPaths(input);
|
|
12
|
-
// NOTE: compatible with windows for `del@5.x`
|
|
13
|
-
files = BalmJS.utils.isArray(input) ? files.map(file => file.replace(/\\/g, '/')) : files.replace(/\\/g, '/');
|
|
14
|
-
return files;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
recipe(input) {
|
|
18
|
-
const balmRemove = async callback => {
|
|
19
|
-
const canDel = !!(BalmJS.utils.isString(input) && input.trim() || BalmJS.utils.isArray(input) && input.length);
|
|
20
|
-
if (canDel) {
|
|
21
|
-
const files = _classPrivateFieldGet(_getFiles, this).call(this, input);
|
|
22
|
-
BalmJS.logger.debug(`${this.name} task`, {
|
|
23
|
-
files
|
|
24
|
-
}, {
|
|
25
|
-
pre: true
|
|
26
|
-
});
|
|
27
|
-
const deletedPaths = await deleteAsync(files, {
|
|
28
|
-
force: true
|
|
29
|
-
});
|
|
30
|
-
BalmJS.logger.warn(`${this.name} task`, {
|
|
31
|
-
deletedPaths
|
|
32
|
-
}, {
|
|
33
|
-
pre: true
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
BalmJS.logger.error(`${this.name} task`, 'Invalid input');
|
|
37
|
-
}
|
|
38
|
-
callback();
|
|
39
|
-
};
|
|
40
|
-
return balmRemove;
|
|
41
|
-
}
|
|
42
|
-
fn(callback) {
|
|
43
|
-
callback();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export default RemoveTask;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
class ReplaceTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('replace');
|
|
4
|
-
}
|
|
5
|
-
recipe(input, output, options) {
|
|
6
|
-
const balmReplace = () => {
|
|
7
|
-
this.init(input, output);
|
|
8
|
-
let stream = this.src;
|
|
9
|
-
if (BalmJS.utils.isArray(options)) {
|
|
10
|
-
const replaceOptions = options;
|
|
11
|
-
replaceOptions.forEach(replaceOption => {
|
|
12
|
-
stream = stream.pipe(BalmJS.plugins.replace(replaceOption.substr, replaceOption.replacement));
|
|
13
|
-
});
|
|
14
|
-
} else {
|
|
15
|
-
const replaceOption = options;
|
|
16
|
-
stream = stream.pipe(BalmJS.plugins.replace(replaceOption.substr, replaceOption.replacement));
|
|
17
|
-
}
|
|
18
|
-
return stream.pipe(gulp.dest(this.output));
|
|
19
|
-
};
|
|
20
|
-
return balmReplace;
|
|
21
|
-
}
|
|
22
|
-
fn(callback) {
|
|
23
|
-
callback();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default ReplaceTask;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import buildLibrary from '../../bundler/rollup/index.js';
|
|
2
|
-
class RollupTask extends BalmJS.BalmTask {
|
|
3
|
-
constructor() {
|
|
4
|
-
super('rollup');
|
|
5
|
-
}
|
|
6
|
-
recipe(input, output) {
|
|
7
|
-
const balmBundler = async callback => {
|
|
8
|
-
await buildLibrary(input, output);
|
|
9
|
-
callback();
|
|
10
|
-
};
|
|
11
|
-
return balmBundler;
|
|
12
|
-
}
|
|
13
|
-
fn(callback) {
|
|
14
|
-
callback();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export default RollupTask;
|
package/lib/tasks/public/sass.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class SassTask extends BalmJS.BalmStyleTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('sass');
|
|
4
|
-
}
|
|
5
|
-
get options() {
|
|
6
|
-
return Object.assign(node.isLegacySass ? {
|
|
7
|
-
includePaths: BalmJS.file.stylePaths,
|
|
8
|
-
outputStyle: 'expanded'
|
|
9
|
-
} : {
|
|
10
|
-
loadPaths: BalmJS.file.stylePaths,
|
|
11
|
-
sourceMap: true
|
|
12
|
-
}, {
|
|
13
|
-
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
14
|
-
}, BalmJS.config.styles.sassOptions, this.customOptions);
|
|
15
|
-
}
|
|
16
|
-
recipe(input, output, options = {}) {
|
|
17
|
-
const balmSass = () => {
|
|
18
|
-
this.init(input, output, options);
|
|
19
|
-
return this.handleStyle(this.name, this.output, this.options);
|
|
20
|
-
};
|
|
21
|
-
return balmSass;
|
|
22
|
-
}
|
|
23
|
-
get fn() {
|
|
24
|
-
return this.recipe();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export default SassTask;
|
|
@@ -1,130 +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 detectPort from '../../utilities/detect-port.js';
|
|
6
|
-
import getMiddlewares from '../../middlewares/index.js';
|
|
7
|
-
var _watchTask = /*#__PURE__*/new WeakMap();
|
|
8
|
-
var _onWatch = /*#__PURE__*/new WeakMap();
|
|
9
|
-
class ServerTask extends BalmJS.BalmTask {
|
|
10
|
-
constructor() {
|
|
11
|
-
super('serve');
|
|
12
|
-
_classPrivateFieldInitSpec(this, _watchTask, (taskName, serverReload = false) => {
|
|
13
|
-
const balmTask = BalmJS.tasks.get(taskName).fn;
|
|
14
|
-
const reload = done => {
|
|
15
|
-
server.reload();
|
|
16
|
-
done();
|
|
17
|
-
};
|
|
18
|
-
return serverReload ? gulp.series(balmTask, reload) : balmTask;
|
|
19
|
-
});
|
|
20
|
-
_classPrivateFieldInitSpec(this, _onWatch, () => {
|
|
21
|
-
const {
|
|
22
|
-
watch
|
|
23
|
-
} = gulp;
|
|
24
|
-
|
|
25
|
-
// NOTE: bugfix for windows - chokidar.cwd has not default
|
|
26
|
-
const watchOptions = {
|
|
27
|
-
cwd: BalmJS.config.workspace
|
|
28
|
-
};
|
|
29
|
-
watch([`${BalmJS.config.src.img}/**/*`, `${BalmJS.config.dest.font}/**/*`, ...BalmJS.config.server.extraWatchFiles], watchOptions).on('change', server.reload);
|
|
30
|
-
watch(`${BalmJS.file.templateBasePath}/*.html`, watchOptions, _classPrivateFieldGet(_watchTask, this).call(this, 'html', true));
|
|
31
|
-
watch(`${BalmJS.config.src.css}/**/*.${BalmJS.config.styles.extname}`, watchOptions, _classPrivateFieldGet(_watchTask, this).call(this, BalmJS.config.inFrontend ? this.styleName : 'style'));
|
|
32
|
-
if (!BalmJS.config.server.useHMR) {
|
|
33
|
-
watch(`${BalmJS.config.src.js}/**/*`, watchOptions, _classPrivateFieldGet(_watchTask, this).call(this, BalmJS.config.scripts.bundler, true));
|
|
34
|
-
}
|
|
35
|
-
watch(`${BalmJS.config.src.base}/modernizr.json`, watchOptions, _classPrivateFieldGet(_watchTask, this).call(this, 'modernizr'));
|
|
36
|
-
watch(`${BalmJS.config.src.font}/**/*`, watchOptions, _classPrivateFieldGet(_watchTask, this).call(this, 'font'));
|
|
37
|
-
|
|
38
|
-
// For FTP
|
|
39
|
-
if (BalmJS.config.ftp.watchFiles.length) {
|
|
40
|
-
watch(BalmJS.config.ftp.watchFiles, watchOptions).on('change', path => {
|
|
41
|
-
BalmJS.logger.debug(`${this.name} task`, `File ${path} was changed`);
|
|
42
|
-
BalmJS.watchFtpFile = path;
|
|
43
|
-
_classPrivateFieldGet(_watchTask, this).call(this, 'ftp', true)();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
if (BalmJS.config.env.isDev) {
|
|
48
|
-
detectPort(BalmJS.config.server.port, BalmJS.config.server.host).then(port => {
|
|
49
|
-
if (BalmJS.config.server.port !== port) {
|
|
50
|
-
BalmJS.logger.warn('server task', `port: ${BalmJS.config.server.port} was occupied, try port: ${port}`);
|
|
51
|
-
BalmJS.config.server.port = port;
|
|
52
|
-
}
|
|
53
|
-
}, () => {});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
recipe(customHandler) {
|
|
57
|
-
const balmServe = callback => {
|
|
58
|
-
if (BalmJS.server) {
|
|
59
|
-
BalmJS.logger.warn('server task', 'Server has started');
|
|
60
|
-
} else {
|
|
61
|
-
const serverConfig = BalmJS.config.server;
|
|
62
|
-
let bsOptions = {
|
|
63
|
-
logPrefix: 'BalmJS',
|
|
64
|
-
notify: false,
|
|
65
|
-
port: serverConfig.port,
|
|
66
|
-
host: serverConfig.host,
|
|
67
|
-
https: serverConfig.https,
|
|
68
|
-
callbacks: {
|
|
69
|
-
ready() {
|
|
70
|
-
if (BalmJS.config.env.isMP) {
|
|
71
|
-
BalmJS.logger.info('提示', `请使用微信开发者工具打开 ${BalmJS.config.roots.tmp} 预览小程序`, {
|
|
72
|
-
logLevel: BalmJS.LogLevel.Error
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
serverConfig.next();
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
open: serverConfig.open,
|
|
79
|
-
localOnly: BalmJS.config.env.inDesktopApp,
|
|
80
|
-
scriptPath: BalmJS.config.scripts.ie8 ? () => '' : undefined
|
|
81
|
-
};
|
|
82
|
-
if (serverConfig.proxy) {
|
|
83
|
-
if (BalmJS.utils.isString(serverConfig.proxy)) {
|
|
84
|
-
bsOptions.proxy = {
|
|
85
|
-
target: serverConfig.proxy
|
|
86
|
-
};
|
|
87
|
-
} else if (BalmJS.utils.isObject(serverConfig.proxy)) {
|
|
88
|
-
bsOptions.proxy = serverConfig.proxy;
|
|
89
|
-
} else {
|
|
90
|
-
BalmJS.logger.error(`${this.name} task`, '`server.proxy` must be a string or object');
|
|
91
|
-
}
|
|
92
|
-
bsOptions.serveStatic = serverConfig.serveStatic;
|
|
93
|
-
} else {
|
|
94
|
-
bsOptions.server = {
|
|
95
|
-
baseDir: [BalmJS.config.dest.base, BalmJS.config.src.base],
|
|
96
|
-
routes: {
|
|
97
|
-
'/bower_components': BalmJS.file.absPath('bower_components'),
|
|
98
|
-
'/node_modules': BalmJS.file.absPath('node_modules')
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
bsOptions.middleware = BalmJS.config.env.isDev ? getMiddlewares() : false;
|
|
103
|
-
bsOptions = BalmJS.utils.deepMerge(bsOptions, serverConfig.options);
|
|
104
|
-
if (BalmJS.config.env.isDev) {
|
|
105
|
-
BalmJS.server = server.init(bsOptions);
|
|
106
|
-
if (BalmJS.config.useDefaults) {
|
|
107
|
-
_classPrivateFieldGet(_onWatch, this).call(this);
|
|
108
|
-
} else {
|
|
109
|
-
BalmJS.watching = true;
|
|
110
|
-
const watcher = gulp.watch([`${BalmJS.config.src.base}/**/*`, ...serverConfig.extraWatchFiles]);
|
|
111
|
-
try {
|
|
112
|
-
customHandler && customHandler(watcher, server.reload);
|
|
113
|
-
} catch (error) {
|
|
114
|
-
const {
|
|
115
|
-
message
|
|
116
|
-
} = error;
|
|
117
|
-
BalmJS.logger.error('balm hook', message);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
callback();
|
|
123
|
-
};
|
|
124
|
-
return balmServe;
|
|
125
|
-
}
|
|
126
|
-
get fn() {
|
|
127
|
-
return this.recipe();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export default ServerTask;
|