balm-core 4.10.0 → 4.12.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/lib/balm.js +0 -20
- package/lib/bootstrap/check_config.js +6 -9
- package/lib/bootstrap/index.js +16 -22
- package/lib/bundler/esbuild/build.js +0 -2
- package/lib/bundler/esbuild/index.js +0 -2
- package/lib/bundler/esbuild/transform.js +0 -4
- package/lib/bundler/rollup/build.js +2 -4
- package/lib/bundler/rollup/entry.js +2 -5
- package/lib/bundler/rollup/index.js +0 -3
- package/lib/bundler/rollup/output.js +0 -5
- package/lib/bundler/rollup/plugins.js +0 -10
- package/lib/bundler/webpack/config/common.js +4 -15
- package/lib/bundler/webpack/config/dev.js +2 -3
- package/lib/bundler/webpack/config/env.js +12 -14
- package/lib/bundler/webpack/config/index.js +0 -2
- package/lib/bundler/webpack/config/prod.js +4 -7
- package/lib/bundler/webpack/entry.js +8 -12
- package/lib/bundler/webpack/index.js +2 -5
- package/lib/bundler/webpack/loaders.js +0 -6
- package/lib/bundler/webpack/output.js +0 -5
- package/lib/bundler/webpack/rules/asset.js +2 -3
- package/lib/bundler/webpack/rules/babel.js +3 -4
- package/lib/bundler/webpack/rules/css.js +4 -10
- package/lib/bundler/webpack/rules/html.js +0 -2
- package/lib/config/assets.js +0 -5
- package/lib/config/env.js +0 -2
- package/lib/config/globals.js +2 -5
- package/lib/config/index.js +0 -5
- package/lib/config/logs.js +0 -1
- package/lib/config/paths.js +3 -3
- package/lib/config/pwa.js +0 -3
- package/lib/config/roots.js +0 -2
- package/lib/config/scripts.js +20 -28
- package/lib/config/server.js +4 -10
- package/lib/config/styles.js +2 -10
- package/lib/hello.js +0 -2
- package/lib/hooks/index.js +18 -35
- package/lib/hooks/maker.js +0 -14
- package/lib/middlewares/history.js +0 -2
- package/lib/middlewares/index.js +0 -4
- package/lib/middlewares/proxy.js +0 -6
- package/lib/middlewares/webpack.js +0 -5
- package/lib/plugins/htmlmin.js +1 -7
- package/lib/plugins/imagemin.js +1 -18
- package/lib/plugins/jsmin.js +0 -10
- package/lib/plugins/less.js +7 -14
- package/lib/plugins/plumber.js +4 -21
- package/lib/plugins/postcss-plugins.js +0 -2
- package/lib/plugins/postcss.js +8 -21
- package/lib/plugins/rename.js +2 -13
- package/lib/plugins/replace.js +4 -22
- package/lib/plugins/sass.js +30 -39
- package/lib/plugins/sftp.js +33 -62
- package/lib/tasks/default.js +10 -19
- package/lib/tasks/foundation/balm.js +0 -25
- package/lib/tasks/foundation/balm_style.js +2 -15
- package/lib/tasks/foundation/index.js +0 -2
- package/lib/tasks/index.js +8 -7
- package/lib/tasks/private/build.js +0 -5
- package/lib/tasks/private/cache.js +0 -6
- package/lib/tasks/private/clean.js +0 -20
- package/lib/tasks/private/end.js +0 -6
- package/lib/tasks/private/extra.js +4 -11
- package/lib/tasks/private/font.js +0 -5
- package/lib/tasks/private/image.js +0 -11
- package/lib/tasks/private/lint.js +0 -5
- package/lib/tasks/private/media.js +0 -5
- package/lib/tasks/private/modernizr.js +0 -19
- package/lib/tasks/private/pwa-cache.js +0 -7
- package/lib/tasks/private/script.js +0 -3
- package/lib/tasks/private/sprite.js +3 -25
- package/lib/tasks/private/start.js +0 -6
- package/lib/tasks/private/style.js +0 -3
- package/lib/tasks/private/workbox-sw.js +0 -5
- package/lib/tasks/public/copy.js +0 -5
- package/lib/tasks/public/esbuild.js +0 -6
- package/lib/tasks/public/ftp.js +0 -11
- package/lib/tasks/public/html.js +0 -20
- package/lib/tasks/public/jsmin.js +0 -6
- package/lib/tasks/public/less.js +0 -6
- package/lib/tasks/public/postcss.js +0 -5
- package/lib/tasks/public/publish.js +3 -15
- package/lib/tasks/public/pwa.js +0 -13
- package/lib/tasks/public/remove.js +2 -18
- package/lib/tasks/public/replace.js +0 -7
- package/lib/tasks/public/rollup.js +0 -6
- package/lib/tasks/public/sass.js +0 -6
- package/lib/tasks/public/server.js +4 -32
- package/lib/tasks/public/url.js +0 -13
- package/lib/tasks/public/version.js +0 -6
- package/lib/tasks/public/webpack.js +2 -12
- package/lib/tasks/public/zip.js +0 -5
- package/lib/utilities/address.js +5 -16
- package/lib/utilities/cache-core.js +5 -13
- package/lib/utilities/color.js +0 -5
- package/lib/utilities/compiling.js +0 -14
- package/lib/utilities/detect-port.js +6 -22
- package/lib/utilities/escape-string-regexp.js +3 -4
- package/lib/utilities/file.js +2 -18
- package/lib/utilities/loading.js +0 -23
- package/lib/utilities/logger.js +0 -19
- package/lib/utilities/merge-stream.js +0 -8
- package/lib/utilities/namespace.js +0 -4
- package/lib/utilities/public-url.js +10 -10
- package/lib/utilities/replacestream.js +5 -27
- package/lib/utilities/typeof.js +0 -2
- package/lib/utilities/utils.js +2 -9
- package/package.json +30 -30
package/lib/tasks/public/html.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
2
|
-
|
|
3
2
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
3
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
6
|
-
|
|
7
4
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
8
|
-
|
|
9
5
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
10
|
-
|
|
11
6
|
import { PUBLIC_URL } from '../../config/constants.js';
|
|
12
|
-
|
|
13
7
|
var _updateAssetsPath = /*#__PURE__*/new WeakMap();
|
|
14
|
-
|
|
15
8
|
var _hasSourcePath = /*#__PURE__*/new WeakMap();
|
|
16
|
-
|
|
17
9
|
class HtmlTask extends BalmJS.BalmTask {
|
|
18
10
|
constructor() {
|
|
19
11
|
super('html');
|
|
20
|
-
|
|
21
12
|
_classPrivateFieldInitSpec(this, _updateAssetsPath, {
|
|
22
13
|
writable: true,
|
|
23
14
|
value: type => {
|
|
@@ -36,23 +27,19 @@ class HtmlTask extends BalmJS.BalmTask {
|
|
|
36
27
|
return BalmJS.plugins.replace(assetsPathSrc, assetsPathDest);
|
|
37
28
|
}
|
|
38
29
|
});
|
|
39
|
-
|
|
40
30
|
_classPrivateFieldInitSpec(this, _hasSourcePath, {
|
|
41
31
|
writable: true,
|
|
42
32
|
value: type => {
|
|
43
33
|
return !!BalmJS.config.paths.source[type];
|
|
44
34
|
}
|
|
45
35
|
});
|
|
46
|
-
|
|
47
36
|
this.defaultInput = [node.path.join(BalmJS.file.templateBasePath, '*.html'), node.path.join(BalmJS.file.templateBasePath, BalmJS.config.pwa.manifest)];
|
|
48
37
|
this.defaultOutput = BalmJS.config.dest.base;
|
|
49
38
|
}
|
|
50
|
-
|
|
51
39
|
recipe(input, output) {
|
|
52
40
|
const balmHtml = () => {
|
|
53
41
|
this.init(input, output);
|
|
54
42
|
let stream = this.src;
|
|
55
|
-
|
|
56
43
|
if (BalmJS.config.env.isProd) {
|
|
57
44
|
stream = stream.pipe($.useref({
|
|
58
45
|
base: BalmJS.config.workspace,
|
|
@@ -60,7 +47,6 @@ class HtmlTask extends BalmJS.BalmTask {
|
|
|
60
47
|
})).pipe($.if(/\.html$/, BalmJS.plugins.htmlmin(BalmJS.config.html.options)));
|
|
61
48
|
['css', 'js', 'img', 'media', 'manifest'].forEach(type => {
|
|
62
49
|
const canUpdate = type === 'manifest' ? BalmJS.config.pwa.enabled : _classPrivateFieldGet(this, _hasSourcePath).call(this, type);
|
|
63
|
-
|
|
64
50
|
if (canUpdate) {
|
|
65
51
|
stream = stream.pipe(_classPrivateFieldGet(this, _updateAssetsPath).call(this, type));
|
|
66
52
|
}
|
|
@@ -69,24 +55,18 @@ class HtmlTask extends BalmJS.BalmTask {
|
|
|
69
55
|
} else {
|
|
70
56
|
['css', 'js', 'img', 'media'].forEach((type, index) => {
|
|
71
57
|
const canUpdate = index > 1 ? _classPrivateFieldGet(this, _hasSourcePath).call(this, type) && !BalmJS.config.inFrontend : _classPrivateFieldGet(this, _hasSourcePath).call(this, type);
|
|
72
|
-
|
|
73
58
|
if (canUpdate) {
|
|
74
59
|
stream = stream.pipe(_classPrivateFieldGet(this, _updateAssetsPath).call(this, type));
|
|
75
60
|
}
|
|
76
61
|
});
|
|
77
62
|
stream = stream.pipe(BalmJS.file.setPublicPath());
|
|
78
63
|
}
|
|
79
|
-
|
|
80
64
|
return stream.pipe(gulp.dest(this.output));
|
|
81
65
|
};
|
|
82
|
-
|
|
83
66
|
return balmHtml;
|
|
84
67
|
}
|
|
85
|
-
|
|
86
68
|
get fn() {
|
|
87
69
|
return this.recipe();
|
|
88
70
|
}
|
|
89
|
-
|
|
90
71
|
}
|
|
91
|
-
|
|
92
72
|
export default HtmlTask;
|
|
@@ -2,12 +2,10 @@ class JsminTask extends BalmJS.BalmTask {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
super('jsmin');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
get options() {
|
|
7
6
|
const defaultOptions = Object.assign({}, BalmJS.config.scripts.minifyOptions);
|
|
8
7
|
return BalmJS.utils.deepMerge(defaultOptions, this.customOptions);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
recipe(input, output, options = {}) {
|
|
12
10
|
const balmJsmin = () => {
|
|
13
11
|
this.init(input, output, options);
|
|
@@ -16,14 +14,10 @@ class JsminTask extends BalmJS.BalmTask {
|
|
|
16
14
|
};
|
|
17
15
|
return this.src.pipe(BalmJS.plugins.jsmin(this.options)).pipe(BalmJS.plugins.rename(renameOptions)).pipe(gulp.dest(this.output));
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
return balmJsmin;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
fn(callback) {
|
|
24
20
|
callback();
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
export default JsminTask;
|
package/lib/tasks/public/less.js
CHANGED
|
@@ -2,26 +2,20 @@ class LessTask extends BalmJS.BalmStyleTask {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
super('less');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
get options() {
|
|
7
6
|
return Object.assign({
|
|
8
7
|
paths: BalmJS.file.stylePaths
|
|
9
8
|
}, BalmJS.config.styles.lessOptions, this.customOptions);
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
recipe(input, output, options = {}) {
|
|
13
11
|
const balmLess = () => {
|
|
14
12
|
this.init(input, output, options);
|
|
15
13
|
return this.handleStyle(this.name, this.output, this.options);
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
return balmLess;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
get fn() {
|
|
22
18
|
return this.recipe();
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
export default LessTask;
|
|
@@ -2,20 +2,15 @@ class PostcssTask extends BalmJS.BalmStyleTask {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
super('postcss');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
recipe(input, output) {
|
|
7
6
|
const balmPostcss = () => {
|
|
8
7
|
this.init(input, output);
|
|
9
8
|
return this.handleStyle(this.name, this.output);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
10
|
return balmPostcss;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
get fn() {
|
|
16
13
|
return this.recipe();
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
export default PostcssTask;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
2
|
-
|
|
3
2
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
3
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
6
|
-
|
|
7
4
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
8
|
-
|
|
9
5
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
10
|
-
|
|
11
6
|
import mergeStream from '../../utilities/merge-stream.js';
|
|
12
|
-
|
|
13
7
|
var _release = /*#__PURE__*/new WeakMap();
|
|
14
|
-
|
|
15
8
|
class PublishTask extends BalmJS.BalmTask {
|
|
16
9
|
constructor() {
|
|
17
10
|
super('publish');
|
|
18
|
-
|
|
19
11
|
_classPrivateFieldInitSpec(this, _release, {
|
|
20
12
|
writable: true,
|
|
21
13
|
value: (input, output, renameOptions = {}) => {
|
|
@@ -25,14 +17,14 @@ class PublishTask extends BalmJS.BalmTask {
|
|
|
25
17
|
} else {
|
|
26
18
|
this.init();
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
return this.src.pipe($.if(!BalmJS.utils.isArray(this.input), BalmJS.plugins.rename(renameOptions))).pipe(gulp.dest(this.output)); // Absolute path
|
|
30
21
|
}
|
|
31
22
|
});
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
this.defaultInput = [BalmJS.file.matchAllFiles(BalmJS.config.dest.static),
|
|
24
|
+
// Assets
|
|
34
25
|
node.path.join(`!${BalmJS.config.dest.base}`, '*.*') // HTML
|
|
35
26
|
];
|
|
27
|
+
|
|
36
28
|
this.defaultOutput = BalmJS.config.assets.static; // Remote dir
|
|
37
29
|
}
|
|
38
30
|
|
|
@@ -50,14 +42,10 @@ class PublishTask extends BalmJS.BalmTask {
|
|
|
50
42
|
callback();
|
|
51
43
|
}
|
|
52
44
|
};
|
|
53
|
-
|
|
54
45
|
return balmPublish;
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
fn(callback) {
|
|
58
48
|
callback();
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
export default PublishTask;
|
package/lib/tasks/public/pwa.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { generateSW, injectManifest } from 'workbox-build';
|
|
2
|
-
|
|
3
2
|
class PwaTask extends BalmJS.BalmTask {
|
|
4
3
|
constructor() {
|
|
5
4
|
super('pwa');
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
setIgnores(options) {
|
|
9
7
|
const defaultIgnores = [BalmJS.config.pwa.swSrcFilename];
|
|
10
|
-
|
|
11
8
|
if (options.globIgnores) {
|
|
12
9
|
options.globIgnores = options.globIgnores.concat(defaultIgnores);
|
|
13
10
|
} else {
|
|
14
11
|
options.globIgnores = defaultIgnores;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
return options;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
recipe(customMode, customOptions = {}) {
|
|
21
16
|
const balmPwa = async callback => {
|
|
22
17
|
const mode = customMode || BalmJS.config.pwa.mode;
|
|
@@ -25,7 +20,6 @@ class PwaTask extends BalmJS.BalmTask {
|
|
|
25
20
|
const swDest = BalmJS.file.absPath(`${globDirectory}/${BalmJS.config.pwa.swDestFilename}`);
|
|
26
21
|
const swSrc = BalmJS.file.absPath(`${BalmJS.config.src.base}/${BalmJS.config.pwa.swSrcFilename}`);
|
|
27
22
|
let valid = true;
|
|
28
|
-
|
|
29
23
|
switch (mode) {
|
|
30
24
|
// For basic
|
|
31
25
|
case 'generateSW':
|
|
@@ -35,7 +29,6 @@ class PwaTask extends BalmJS.BalmTask {
|
|
|
35
29
|
}, BalmJS.config.pwa.options, customOptions);
|
|
36
30
|
break;
|
|
37
31
|
// For advanced
|
|
38
|
-
|
|
39
32
|
case 'injectManifest':
|
|
40
33
|
options = Object.assign({
|
|
41
34
|
globDirectory,
|
|
@@ -43,11 +36,9 @@ class PwaTask extends BalmJS.BalmTask {
|
|
|
43
36
|
swSrc
|
|
44
37
|
}, BalmJS.config.pwa.options, customOptions);
|
|
45
38
|
break;
|
|
46
|
-
|
|
47
39
|
default:
|
|
48
40
|
valid = false;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
if (valid) {
|
|
52
43
|
options = this.setIgnores(options);
|
|
53
44
|
BalmJS.logger.debug(`pwa - ${mode}`, options, {
|
|
@@ -69,14 +60,10 @@ class PwaTask extends BalmJS.BalmTask {
|
|
|
69
60
|
callback();
|
|
70
61
|
}
|
|
71
62
|
};
|
|
72
|
-
|
|
73
63
|
return balmPwa;
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
get fn() {
|
|
77
66
|
return this.recipe();
|
|
78
67
|
}
|
|
79
|
-
|
|
80
68
|
}
|
|
81
|
-
|
|
82
69
|
export default PwaTask;
|
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
2
|
-
|
|
3
2
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
3
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
6
|
-
|
|
7
4
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
8
|
-
|
|
9
5
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
10
|
-
|
|
11
6
|
import { deleteAsync } from 'del';
|
|
12
|
-
|
|
13
7
|
var _getFiles = /*#__PURE__*/new WeakMap();
|
|
14
|
-
|
|
15
8
|
class RemoveTask extends BalmJS.BalmTask {
|
|
16
9
|
constructor() {
|
|
17
10
|
super('remove');
|
|
18
|
-
|
|
19
11
|
_classPrivateFieldInitSpec(this, _getFiles, {
|
|
20
12
|
writable: true,
|
|
21
13
|
value: input => {
|
|
22
|
-
let files = BalmJS.file.absPaths(input);
|
|
23
|
-
|
|
14
|
+
let files = BalmJS.file.absPaths(input);
|
|
15
|
+
// NOTE: compatible with windows for `del@5.x`
|
|
24
16
|
files = BalmJS.utils.isArray(input) ? files.map(file => file.replace(/\\/g, '/')) : files.replace(/\\/g, '/');
|
|
25
17
|
return files;
|
|
26
18
|
}
|
|
27
19
|
});
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
recipe(input) {
|
|
31
22
|
const balmRemove = async callback => {
|
|
32
23
|
const canDel = !!(BalmJS.utils.isString(input) && input.trim() || BalmJS.utils.isArray(input) && input.length);
|
|
33
|
-
|
|
34
24
|
if (canDel) {
|
|
35
25
|
const files = _classPrivateFieldGet(this, _getFiles).call(this, input);
|
|
36
|
-
|
|
37
26
|
BalmJS.logger.debug(`${this.name} task`, {
|
|
38
27
|
files
|
|
39
28
|
}, {
|
|
@@ -50,17 +39,12 @@ class RemoveTask extends BalmJS.BalmTask {
|
|
|
50
39
|
} else {
|
|
51
40
|
BalmJS.logger.error(`${this.name} task`, 'Invalid input');
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
callback();
|
|
55
43
|
};
|
|
56
|
-
|
|
57
44
|
return balmRemove;
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
fn(callback) {
|
|
61
47
|
callback();
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
}
|
|
65
|
-
|
|
66
50
|
export default RemoveTask;
|
|
@@ -2,12 +2,10 @@ class ReplaceTask extends BalmJS.BalmTask {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
super('replace');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
recipe(input, output, options) {
|
|
7
6
|
const balmReplace = () => {
|
|
8
7
|
this.init(input, output);
|
|
9
8
|
let stream = this.src;
|
|
10
|
-
|
|
11
9
|
if (BalmJS.utils.isArray(options)) {
|
|
12
10
|
const replaceOptions = options;
|
|
13
11
|
replaceOptions.forEach(replaceOption => {
|
|
@@ -17,17 +15,12 @@ class ReplaceTask extends BalmJS.BalmTask {
|
|
|
17
15
|
const replaceOption = options;
|
|
18
16
|
stream = stream.pipe(BalmJS.plugins.replace(replaceOption.substr, replaceOption.replacement));
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
return stream.pipe(gulp.dest(this.output));
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
return balmReplace;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
fn(callback) {
|
|
28
23
|
callback();
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
export default ReplaceTask;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import buildLibrary from '../../bundler/rollup/index.js';
|
|
2
|
-
|
|
3
2
|
class RollupTask extends BalmJS.BalmTask {
|
|
4
3
|
constructor() {
|
|
5
4
|
super('rollup');
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
recipe(input, output) {
|
|
9
7
|
const balmBundler = async callback => {
|
|
10
8
|
await buildLibrary(input, output);
|
|
11
9
|
callback();
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return balmBundler;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
fn(callback) {
|
|
18
14
|
callback();
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
export default RollupTask;
|
package/lib/tasks/public/sass.js
CHANGED
|
@@ -2,7 +2,6 @@ class SassTask extends BalmJS.BalmStyleTask {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
super('sass');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
get options() {
|
|
7
6
|
return Object.assign({
|
|
8
7
|
includePaths: BalmJS.file.stylePaths,
|
|
@@ -10,20 +9,15 @@ class SassTask extends BalmJS.BalmStyleTask {
|
|
|
10
9
|
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
11
10
|
}, BalmJS.config.styles.sassOptions, this.customOptions);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
recipe(input, output, options = {}) {
|
|
15
13
|
const balmSass = () => {
|
|
16
14
|
this.init(input, output, options);
|
|
17
15
|
return this.handleStyle(this.name, this.output, this.options);
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
return balmSass;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
get fn() {
|
|
24
20
|
return this.recipe();
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
export default SassTask;
|
|
@@ -1,70 +1,56 @@
|
|
|
1
1
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
2
|
-
|
|
3
2
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
3
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
6
|
-
|
|
7
4
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
8
|
-
|
|
9
5
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
10
|
-
|
|
11
6
|
import detectPort from '../../utilities/detect-port.js';
|
|
12
7
|
import getMiddlewares from '../../middlewares/index.js';
|
|
13
|
-
|
|
14
8
|
var _watchTask = /*#__PURE__*/new WeakMap();
|
|
15
|
-
|
|
16
9
|
var _onWatch = /*#__PURE__*/new WeakMap();
|
|
17
|
-
|
|
18
10
|
class ServerTask extends BalmJS.BalmTask {
|
|
19
11
|
constructor() {
|
|
20
12
|
super('serve');
|
|
21
|
-
|
|
22
13
|
_classPrivateFieldInitSpec(this, _watchTask, {
|
|
23
14
|
writable: true,
|
|
24
15
|
value: (taskName, serverReload = false) => {
|
|
25
16
|
const balmTask = BalmJS.tasks.get(taskName).fn;
|
|
26
|
-
|
|
27
17
|
const reload = done => {
|
|
28
18
|
server.reload();
|
|
29
19
|
done();
|
|
30
20
|
};
|
|
31
|
-
|
|
32
21
|
return serverReload ? gulp.series(balmTask, reload) : balmTask;
|
|
33
22
|
}
|
|
34
23
|
});
|
|
35
|
-
|
|
36
24
|
_classPrivateFieldInitSpec(this, _onWatch, {
|
|
37
25
|
writable: true,
|
|
38
26
|
value: () => {
|
|
39
27
|
const {
|
|
40
28
|
watch
|
|
41
|
-
} = gulp;
|
|
29
|
+
} = gulp;
|
|
42
30
|
|
|
31
|
+
// NOTE: bugfix for windows - chokidar.cwd has not default
|
|
43
32
|
const watchOptions = {
|
|
44
33
|
cwd: BalmJS.config.workspace
|
|
45
34
|
};
|
|
46
35
|
watch([`${BalmJS.config.src.img}/**/*`, `${BalmJS.config.dest.font}/**/*`, ...BalmJS.config.server.extraWatchFiles], watchOptions).on('change', server.reload);
|
|
47
36
|
watch(`${BalmJS.file.templateBasePath}/*.html`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, 'html', true));
|
|
48
37
|
watch(`${BalmJS.config.src.css}/**/*.${BalmJS.config.styles.extname}`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, BalmJS.config.inFrontend ? this.styleName : 'style'));
|
|
49
|
-
|
|
50
38
|
if (!BalmJS.config.server.useHMR) {
|
|
51
39
|
watch(`${BalmJS.config.src.js}/**/*`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, BalmJS.config.scripts.bundler, true));
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
watch(`${BalmJS.config.src.base}/modernizr.json`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, 'modernizr'));
|
|
55
|
-
watch(`${BalmJS.config.src.font}/**/*`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, 'font'));
|
|
42
|
+
watch(`${BalmJS.config.src.font}/**/*`, watchOptions, _classPrivateFieldGet(this, _watchTask).call(this, 'font'));
|
|
56
43
|
|
|
44
|
+
// For FTP
|
|
57
45
|
if (BalmJS.config.ftp.watchFiles.length) {
|
|
58
46
|
watch(BalmJS.config.ftp.watchFiles, watchOptions).on('change', path => {
|
|
59
47
|
BalmJS.logger.debug(`${this.name} task`, `File ${path} was changed`);
|
|
60
48
|
BalmJS.watchFtpFile = path;
|
|
61
|
-
|
|
62
49
|
_classPrivateFieldGet(this, _watchTask).call(this, 'ftp', true)();
|
|
63
50
|
});
|
|
64
51
|
}
|
|
65
52
|
}
|
|
66
53
|
});
|
|
67
|
-
|
|
68
54
|
if (BalmJS.config.env.isDev) {
|
|
69
55
|
detectPort(BalmJS.config.server.port, BalmJS.config.server.host).then(port => {
|
|
70
56
|
if (BalmJS.config.server.port !== port) {
|
|
@@ -74,7 +60,6 @@ class ServerTask extends BalmJS.BalmTask {
|
|
|
74
60
|
}, () => {});
|
|
75
61
|
}
|
|
76
62
|
}
|
|
77
|
-
|
|
78
63
|
recipe(customHandler) {
|
|
79
64
|
const balmServe = callback => {
|
|
80
65
|
if (BalmJS.server) {
|
|
@@ -94,16 +79,13 @@ class ServerTask extends BalmJS.BalmTask {
|
|
|
94
79
|
logLevel: BalmJS.LogLevel.Error
|
|
95
80
|
});
|
|
96
81
|
}
|
|
97
|
-
|
|
98
82
|
serverConfig.next();
|
|
99
83
|
}
|
|
100
|
-
|
|
101
84
|
},
|
|
102
85
|
open: serverConfig.open,
|
|
103
86
|
localOnly: BalmJS.config.env.inDesktopApp,
|
|
104
87
|
scriptPath: BalmJS.config.scripts.ie8 ? () => '' : undefined
|
|
105
88
|
};
|
|
106
|
-
|
|
107
89
|
if (serverConfig.proxy) {
|
|
108
90
|
if (BalmJS.utils.isString(serverConfig.proxy)) {
|
|
109
91
|
bsOptions.proxy = {
|
|
@@ -114,7 +96,6 @@ class ServerTask extends BalmJS.BalmTask {
|
|
|
114
96
|
} else {
|
|
115
97
|
BalmJS.logger.error(`${this.name} task`, '`server.proxy` must be a string or object');
|
|
116
98
|
}
|
|
117
|
-
|
|
118
99
|
bsOptions.serveStatic = serverConfig.serveStatic;
|
|
119
100
|
} else {
|
|
120
101
|
bsOptions.server = {
|
|
@@ -125,19 +106,15 @@ class ServerTask extends BalmJS.BalmTask {
|
|
|
125
106
|
}
|
|
126
107
|
};
|
|
127
108
|
}
|
|
128
|
-
|
|
129
109
|
bsOptions.middleware = BalmJS.config.env.isDev ? getMiddlewares() : false;
|
|
130
110
|
bsOptions = BalmJS.utils.deepMerge(bsOptions, serverConfig.options);
|
|
131
|
-
|
|
132
111
|
if (BalmJS.config.env.isDev) {
|
|
133
112
|
BalmJS.server = server.init(bsOptions);
|
|
134
|
-
|
|
135
113
|
if (BalmJS.config.useDefaults) {
|
|
136
114
|
_classPrivateFieldGet(this, _onWatch).call(this);
|
|
137
115
|
} else {
|
|
138
116
|
BalmJS.watching = true;
|
|
139
117
|
const watcher = gulp.watch([`${BalmJS.config.src.base}/**/*`, ...serverConfig.extraWatchFiles]);
|
|
140
|
-
|
|
141
118
|
try {
|
|
142
119
|
customHandler && customHandler(watcher, server.reload);
|
|
143
120
|
} catch (error) {
|
|
@@ -149,17 +126,12 @@ class ServerTask extends BalmJS.BalmTask {
|
|
|
149
126
|
}
|
|
150
127
|
}
|
|
151
128
|
}
|
|
152
|
-
|
|
153
129
|
callback();
|
|
154
130
|
};
|
|
155
|
-
|
|
156
131
|
return balmServe;
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
get fn() {
|
|
160
134
|
return this.recipe();
|
|
161
135
|
}
|
|
162
|
-
|
|
163
136
|
}
|
|
164
|
-
|
|
165
137
|
export default ServerTask;
|
package/lib/tasks/public/url.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
2
|
-
|
|
3
2
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
4
|
-
|
|
5
3
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
6
|
-
|
|
7
4
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
8
|
-
|
|
9
5
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
10
|
-
|
|
11
6
|
var _urlProcessing = /*#__PURE__*/new WeakMap();
|
|
12
|
-
|
|
13
7
|
class UrlTask extends BalmJS.BalmTask {
|
|
14
8
|
constructor() {
|
|
15
9
|
super('url');
|
|
16
|
-
|
|
17
10
|
_classPrivateFieldInitSpec(this, _urlProcessing, {
|
|
18
11
|
writable: true,
|
|
19
12
|
value: type => {
|
|
@@ -29,24 +22,18 @@ class UrlTask extends BalmJS.BalmTask {
|
|
|
29
22
|
return BalmJS.plugins.replace(pathSrc, pathDest);
|
|
30
23
|
}
|
|
31
24
|
});
|
|
32
|
-
|
|
33
25
|
this.defaultOutput = BalmJS.config.dest.css;
|
|
34
26
|
this.defaultInput = BalmJS.file.matchAllFiles(this.defaultOutput, '*.css');
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
recipe(input, output) {
|
|
38
29
|
const balmUrl = () => {
|
|
39
30
|
this.init(input, output);
|
|
40
31
|
return this.src.pipe(_classPrivateFieldGet(this, _urlProcessing).call(this, 'img')).pipe(_classPrivateFieldGet(this, _urlProcessing).call(this, 'font')).pipe(gulp.dest(this.output));
|
|
41
32
|
};
|
|
42
|
-
|
|
43
33
|
return balmUrl;
|
|
44
34
|
}
|
|
45
|
-
|
|
46
35
|
get fn() {
|
|
47
36
|
return this.recipe();
|
|
48
37
|
}
|
|
49
|
-
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
export default UrlTask;
|
|
@@ -3,11 +3,9 @@ class VersionTask extends BalmJS.BalmTask {
|
|
|
3
3
|
super('version');
|
|
4
4
|
this.defaultOutput = BalmJS.config.dest.base;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
get options() {
|
|
8
7
|
return Object.assign({}, BalmJS.config.assets.options, this.customOptions);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
recipe(input, output, assetsOptions) {
|
|
12
10
|
const balmVersion = () => {
|
|
13
11
|
this.init(input, output, {
|
|
@@ -15,14 +13,10 @@ class VersionTask extends BalmJS.BalmTask {
|
|
|
15
13
|
});
|
|
16
14
|
return this.src.pipe($.revAll.revision(this.options)).pipe(gulp.dest(this.output)).pipe($.revAll.versionFile()).pipe(gulp.dest(this.output));
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
return balmVersion;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
fn(callback) {
|
|
23
19
|
callback();
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
export default VersionTask;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { webpack, webpackConfig } from '../../bundler/webpack/index.js';
|
|
2
2
|
import compiling from '../../utilities/compiling.js';
|
|
3
|
-
|
|
4
3
|
class WebpackTask extends BalmJS.BalmTask {
|
|
5
4
|
constructor() {
|
|
6
5
|
super('webpack');
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
recipe(input, output, customOptions = {}, fn) {
|
|
10
8
|
const balmBundler = callback => {
|
|
11
9
|
this.init(input || BalmJS.config.scripts.entry, output);
|
|
@@ -13,37 +11,29 @@ class WebpackTask extends BalmJS.BalmTask {
|
|
|
13
11
|
compiling.start();
|
|
14
12
|
BalmJS.webpackCompiler = webpack(webpackConfig(this.input, this.output, customOptions, isHook), (error, stats) => {
|
|
15
13
|
compiling.stop();
|
|
16
|
-
|
|
17
14
|
try {
|
|
18
15
|
const scriptLogLevel = stats.hasErrors() ? BalmJS.LogLevel.Error : stats.hasWarnings() ? BalmJS.LogLevel.Warn : BalmJS.LogLevel.Info;
|
|
19
|
-
|
|
20
16
|
if (BalmJS.config.logs.level <= scriptLogLevel) {
|
|
21
17
|
console.log(stats.toString(BalmJS.config.scripts.stats));
|
|
22
18
|
}
|
|
23
19
|
} catch (e) {
|
|
24
20
|
// Handle errors here
|
|
25
21
|
BalmJS.logger.error(`${this.name} task`, error.stack || error);
|
|
26
|
-
|
|
27
22
|
if (error.details) {
|
|
28
23
|
BalmJS.logger.error(`${this.name} task`, error.details);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
27
|
+
fn && fn();
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
// Done processing
|
|
36
30
|
callback();
|
|
37
31
|
});
|
|
38
32
|
};
|
|
39
|
-
|
|
40
33
|
return balmBundler;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
get fn() {
|
|
44
36
|
return this.recipe();
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
export default WebpackTask;
|