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,95 +0,0 @@
|
|
|
1
|
-
import { Transform } from 'node:stream';
|
|
2
|
-
import * as sass from 'sass';
|
|
3
|
-
import replaceExtension from 'replace-ext';
|
|
4
|
-
import stripAnsi from 'strip-ansi';
|
|
5
|
-
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
6
|
-
import ansiColors from 'ansi-colors';
|
|
7
|
-
const sassModule = node.getSassModule(sass);
|
|
8
|
-
const PLUGIN_NAME = 'sass-legacy';
|
|
9
|
-
const transformObj = (transform) => new Transform({ transform, objectMode: true });
|
|
10
|
-
function filePush(file, sassObject, callback) {
|
|
11
|
-
if (sassObject.map) {
|
|
12
|
-
const sassMap = JSON.parse(sassObject.map.toString());
|
|
13
|
-
const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
14
|
-
const sassFileSrc = file.relative;
|
|
15
|
-
const sassFileSrcPath = node.path.dirname(sassFileSrc);
|
|
16
|
-
if (sassFileSrcPath) {
|
|
17
|
-
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
18
|
-
sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex
|
|
19
|
-
? source
|
|
20
|
-
: node.path.join(sassFileSrcPath, source));
|
|
21
|
-
}
|
|
22
|
-
sassMap.sources = sassMap.sources.filter((src) => src !== 'stdin' && src);
|
|
23
|
-
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
24
|
-
applySourceMap(file, sassMap);
|
|
25
|
-
}
|
|
26
|
-
file.contents = sassObject.css;
|
|
27
|
-
file.path = replaceExtension(file.path, '.css');
|
|
28
|
-
if (file.stat) {
|
|
29
|
-
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
30
|
-
}
|
|
31
|
-
callback(null, file);
|
|
32
|
-
}
|
|
33
|
-
function handleError(error, file, callback) {
|
|
34
|
-
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
35
|
-
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
36
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
|
|
37
|
-
error.messageFormatted = message;
|
|
38
|
-
error.messageOriginal = error.message;
|
|
39
|
-
error.message = stripAnsi(message);
|
|
40
|
-
error.relativePath = relativePath;
|
|
41
|
-
return callback(new PluginError(PLUGIN_NAME, error));
|
|
42
|
-
}
|
|
43
|
-
const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
|
|
44
|
-
if (file.isNull()) {
|
|
45
|
-
return callback(null, file);
|
|
46
|
-
}
|
|
47
|
-
if (file.isStream()) {
|
|
48
|
-
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
49
|
-
}
|
|
50
|
-
if (node.path.basename(file.path).startsWith('_')) {
|
|
51
|
-
return callback();
|
|
52
|
-
}
|
|
53
|
-
if (!file.contents.length) {
|
|
54
|
-
file.path = replaceExtension(file.path, '.css');
|
|
55
|
-
return callback(null, file);
|
|
56
|
-
}
|
|
57
|
-
const opts = (options || {});
|
|
58
|
-
opts.data = file.contents.toString();
|
|
59
|
-
opts.file = file.path;
|
|
60
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
61
|
-
opts.indentedSyntax = true;
|
|
62
|
-
}
|
|
63
|
-
if (opts.includePaths) {
|
|
64
|
-
if (typeof opts.includePaths === 'string') {
|
|
65
|
-
opts.includePaths = [opts.includePaths];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
opts.includePaths = [];
|
|
70
|
-
}
|
|
71
|
-
opts.includePaths.unshift(node.path.dirname(file.path));
|
|
72
|
-
if (file.sourceMap) {
|
|
73
|
-
opts.sourceMap = file.path;
|
|
74
|
-
opts.omitSourceMapUrl = true;
|
|
75
|
-
opts.sourceMapContents = true;
|
|
76
|
-
}
|
|
77
|
-
if (sync !== true) {
|
|
78
|
-
sassModule.render(opts, (error, obj) => {
|
|
79
|
-
if (error) {
|
|
80
|
-
handleError(error, file, callback);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
filePush(file, obj, callback);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
try {
|
|
88
|
-
filePush(file, sassModule.renderSync(opts), callback);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
handleError(error, file, callback);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
export default gulpSass;
|
package/tslib/plugins/sass.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Transform } from 'node:stream';
|
|
2
|
-
import * as sass from 'sass';
|
|
3
|
-
import replaceExtension from 'replace-ext';
|
|
4
|
-
import stripAnsi from 'strip-ansi';
|
|
5
|
-
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
6
|
-
import ansiColors from 'ansi-colors';
|
|
7
|
-
const sassModule = node.getSassModule(sass);
|
|
8
|
-
const PLUGIN_NAME = 'sass';
|
|
9
|
-
const transformObj = (transform) => new Transform({ transform, objectMode: true });
|
|
10
|
-
function filePush(file, result, callback) {
|
|
11
|
-
file.contents = Buffer.from(result.css);
|
|
12
|
-
file.path = replaceExtension(file.path, '.css');
|
|
13
|
-
if (result.sourceMap) {
|
|
14
|
-
const proto = /^file:\/\/?/;
|
|
15
|
-
const leadingSlash = /^\//;
|
|
16
|
-
const sassMap = result.sourceMap;
|
|
17
|
-
const base = node.path.resolve(file.cwd, file.base);
|
|
18
|
-
if (!sassMap.file) {
|
|
19
|
-
sassMap.file = file.history[0]
|
|
20
|
-
.replace(base + node.path.sep, '')
|
|
21
|
-
.replace(proto, '');
|
|
22
|
-
}
|
|
23
|
-
sassMap.sources = sassMap.sources.map((src) => {
|
|
24
|
-
const baseUri = base.replace(/\\/g, '/');
|
|
25
|
-
if (src.startsWith('data:')) {
|
|
26
|
-
return file.history[0]
|
|
27
|
-
.replace(/\\/g, '/')
|
|
28
|
-
.replace(`${baseUri}/`, '')
|
|
29
|
-
.replace(proto, '')
|
|
30
|
-
.replace(leadingSlash, '');
|
|
31
|
-
}
|
|
32
|
-
return src
|
|
33
|
-
.replace(proto, '')
|
|
34
|
-
.replace(`${baseUri}/`, '')
|
|
35
|
-
.replace(leadingSlash, '');
|
|
36
|
-
});
|
|
37
|
-
const sassFileSrc = file.relative;
|
|
38
|
-
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
39
|
-
if (file.sourceMap &&
|
|
40
|
-
file.sourceMap.sourcesContent &&
|
|
41
|
-
!sassMap.sourcesContent) {
|
|
42
|
-
sassMap.sourcesContent = file.sourceMap.sourcesContent;
|
|
43
|
-
}
|
|
44
|
-
applySourceMap(file, sassMap);
|
|
45
|
-
}
|
|
46
|
-
if (file.stat) {
|
|
47
|
-
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
48
|
-
}
|
|
49
|
-
callback(null, file);
|
|
50
|
-
}
|
|
51
|
-
function handleError(error, file, callback) {
|
|
52
|
-
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
53
|
-
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
54
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.message}`;
|
|
55
|
-
error.message = stripAnsi(message);
|
|
56
|
-
return callback(new PluginError(PLUGIN_NAME, error));
|
|
57
|
-
}
|
|
58
|
-
const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
|
|
59
|
-
if (file.isNull()) {
|
|
60
|
-
return callback(null, file);
|
|
61
|
-
}
|
|
62
|
-
if (file.isStream()) {
|
|
63
|
-
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
64
|
-
}
|
|
65
|
-
if (node.path.basename(file.path).startsWith('_')) {
|
|
66
|
-
return callback();
|
|
67
|
-
}
|
|
68
|
-
if (!file.contents.length) {
|
|
69
|
-
file.path = replaceExtension(file.path, '.css');
|
|
70
|
-
return callback(null, file);
|
|
71
|
-
}
|
|
72
|
-
const opts = (options || {});
|
|
73
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
74
|
-
opts.syntax = 'indented';
|
|
75
|
-
}
|
|
76
|
-
if (opts.loadPaths) {
|
|
77
|
-
if (typeof opts.loadPaths === 'string') {
|
|
78
|
-
opts.loadPaths = [opts.loadPaths];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
opts.loadPaths = [];
|
|
83
|
-
}
|
|
84
|
-
opts.loadPaths.unshift(node.path.dirname(file.path));
|
|
85
|
-
if (file.sourceMap) {
|
|
86
|
-
opts.sourceMap = true;
|
|
87
|
-
opts.sourceMapIncludeSources = true;
|
|
88
|
-
}
|
|
89
|
-
const fileContents = file.contents.toString();
|
|
90
|
-
if (sync !== true) {
|
|
91
|
-
sassModule
|
|
92
|
-
.compileStringAsync(fileContents, opts)
|
|
93
|
-
.then((compileResult) => {
|
|
94
|
-
filePush(file, compileResult, callback);
|
|
95
|
-
})
|
|
96
|
-
.catch((error) => {
|
|
97
|
-
handleError(error, file, callback);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
try {
|
|
102
|
-
filePush(file, sassModule.compileString(fileContents, opts), callback);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
handleError(error, file, callback);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
export default gulpSass;
|
package/tslib/plugins/sftp.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { Client } from 'ssh2';
|
|
2
|
-
import parents from 'parents';
|
|
3
|
-
import async from 'async';
|
|
4
|
-
const PLUGIN_NAME = 'sftp';
|
|
5
|
-
const DefaultAlgorithms = {
|
|
6
|
-
kex: [
|
|
7
|
-
'curve25519-sha256',
|
|
8
|
-
'curve25519-sha256@libssh.org',
|
|
9
|
-
'ecdh-sha2-nistp256',
|
|
10
|
-
'ecdh-sha2-nistp384',
|
|
11
|
-
'ecdh-sha2-nistp521',
|
|
12
|
-
'diffie-hellman-group-exchange-sha256',
|
|
13
|
-
'diffie-hellman-group14-sha256',
|
|
14
|
-
'diffie-hellman-group15-sha512',
|
|
15
|
-
'diffie-hellman-group16-sha512',
|
|
16
|
-
'diffie-hellman-group17-sha512',
|
|
17
|
-
'diffie-hellman-group18-sha512',
|
|
18
|
-
'diffie-hellman-group-exchange-sha1',
|
|
19
|
-
'diffie-hellman-group14-sha1',
|
|
20
|
-
'diffie-hellman-group1-sha1'
|
|
21
|
-
]
|
|
22
|
-
};
|
|
23
|
-
const normalizePath = (_path) => _path.replace(/\\/g, '/');
|
|
24
|
-
function resolveHomePath(key) {
|
|
25
|
-
if (key.location) {
|
|
26
|
-
const HOME = process.env.HOME || process.env.USERPROFILE || '';
|
|
27
|
-
for (let i = 0, len = key.location.length; i < len; i++) {
|
|
28
|
-
if (key.location[i].substr(0, 2) === '~/') {
|
|
29
|
-
key.location[i] = node.path.resolve(HOME, key.location[i].replace(/^~\//, ''));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
for (let i = 0, keyPath; (keyPath = key.location[i++]);) {
|
|
33
|
-
if (node.fs.existsSync(keyPath)) {
|
|
34
|
-
key.contents = node.fs.readFileSync(keyPath);
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (!key.contents) {
|
|
40
|
-
const rsaKey = key.location.join(', ');
|
|
41
|
-
throw new PluginError(PLUGIN_NAME, `Cannot find RSA key, searched: ${rsaKey}`);
|
|
42
|
-
}
|
|
43
|
-
return key;
|
|
44
|
-
}
|
|
45
|
-
function getKey(options) {
|
|
46
|
-
let key = options.key || options.keyLocation || null;
|
|
47
|
-
if (key && BalmJS.utils.isString(key)) {
|
|
48
|
-
key = {
|
|
49
|
-
location: key
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (!key &&
|
|
53
|
-
(options.passphrase || options.keyContents || !options.password)) {
|
|
54
|
-
key = {};
|
|
55
|
-
}
|
|
56
|
-
if (key) {
|
|
57
|
-
key.contents = key.contents || options.keyContents;
|
|
58
|
-
key.passphrase = key.passphrase || options.passphrase;
|
|
59
|
-
key.location = key.location || [
|
|
60
|
-
'~/.ssh/id_rsa',
|
|
61
|
-
'/.ssh/id_rsa',
|
|
62
|
-
'~/.ssh/id_dsa',
|
|
63
|
-
'/.ssh/id_dsa'
|
|
64
|
-
];
|
|
65
|
-
if (!BalmJS.utils.isArray(key.location)) {
|
|
66
|
-
key.location = [key.location];
|
|
67
|
-
}
|
|
68
|
-
key = resolveHomePath(key);
|
|
69
|
-
}
|
|
70
|
-
return key;
|
|
71
|
-
}
|
|
72
|
-
function gulpSftp(options) {
|
|
73
|
-
options = Object.assign({}, options);
|
|
74
|
-
if (!options.host) {
|
|
75
|
-
throw new PluginError(PLUGIN_NAME, '`host` required');
|
|
76
|
-
}
|
|
77
|
-
let fileCount = 0;
|
|
78
|
-
const remotePath = options.remotePath || '/';
|
|
79
|
-
const remotePlatform = options.remotePlatform || options.platform || 'unix';
|
|
80
|
-
options.authKey = options.authKey || options.auth;
|
|
81
|
-
const authFilePath = options.authFile || '.ftppass';
|
|
82
|
-
const authFile = node.path.join('./', authFilePath);
|
|
83
|
-
if (options.authKey && node.fs.existsSync(authFile)) {
|
|
84
|
-
let auth = JSON.parse(node.fs.readFileSync(authFile, 'utf8'))[options.authKey];
|
|
85
|
-
if (!auth) {
|
|
86
|
-
throw new PluginError(PLUGIN_NAME, 'Could not find authkey in .ftppass');
|
|
87
|
-
}
|
|
88
|
-
if (BalmJS.utils.isString(auth) && auth.indexOf(':') !== -1) {
|
|
89
|
-
const authparts = auth.split(':');
|
|
90
|
-
auth = { user: authparts[0], pass: authparts[1] };
|
|
91
|
-
}
|
|
92
|
-
const authKeys = Object.keys(auth);
|
|
93
|
-
for (let i = 0, len = authKeys.length; i < len; i++) {
|
|
94
|
-
const attr = authKeys[i];
|
|
95
|
-
if (auth[attr]) {
|
|
96
|
-
options[attr] = auth[attr];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const password = options.password;
|
|
101
|
-
const username = options.username || 'anonymous';
|
|
102
|
-
const key = getKey(options);
|
|
103
|
-
const mkDirCache = {};
|
|
104
|
-
let finished = false;
|
|
105
|
-
let sftpCache = null;
|
|
106
|
-
let connCache = null;
|
|
107
|
-
function _pool(uploader) {
|
|
108
|
-
if (sftpCache) {
|
|
109
|
-
return uploader(sftpCache);
|
|
110
|
-
}
|
|
111
|
-
if (password) {
|
|
112
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with password');
|
|
113
|
-
}
|
|
114
|
-
else if (key) {
|
|
115
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Authenticating with private key');
|
|
116
|
-
}
|
|
117
|
-
const connectionOptions = {
|
|
118
|
-
host: options.host,
|
|
119
|
-
port: options.port || 22,
|
|
120
|
-
username,
|
|
121
|
-
algorithms: options.algorithms || DefaultAlgorithms
|
|
122
|
-
};
|
|
123
|
-
if (password) {
|
|
124
|
-
connectionOptions.password = password;
|
|
125
|
-
}
|
|
126
|
-
else if (options.agent) {
|
|
127
|
-
connectionOptions.agent = options.agent;
|
|
128
|
-
connectionOptions.agentForward = options.agentForward || false;
|
|
129
|
-
}
|
|
130
|
-
else if (key) {
|
|
131
|
-
connectionOptions.privateKey = key.contents;
|
|
132
|
-
connectionOptions.passphrase = key.passphrase;
|
|
133
|
-
}
|
|
134
|
-
if (options.timeout) {
|
|
135
|
-
connectionOptions.readyTimeout = options.timeout;
|
|
136
|
-
}
|
|
137
|
-
const conn = new Client();
|
|
138
|
-
connCache = conn;
|
|
139
|
-
conn.on('ready', () => {
|
|
140
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Client :: ready');
|
|
141
|
-
conn.sftp((err, sftp) => {
|
|
142
|
-
if (err) {
|
|
143
|
-
throw err;
|
|
144
|
-
}
|
|
145
|
-
sftp.on('end', function () {
|
|
146
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'SFTP session closed');
|
|
147
|
-
sftpCache = null;
|
|
148
|
-
if (!finished) {
|
|
149
|
-
this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
sftpCache = sftp;
|
|
153
|
-
uploader(sftpCache);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
conn.on('error', (err) => {
|
|
157
|
-
const errorMsg = (err && (err.message || err.toString())) || 'SFTP connection error';
|
|
158
|
-
this.emit('error', new PluginError(PLUGIN_NAME, errorMsg));
|
|
159
|
-
});
|
|
160
|
-
conn.on('end', () => {
|
|
161
|
-
BalmJS.logger.debug(PLUGIN_NAME, 'Client :: end');
|
|
162
|
-
});
|
|
163
|
-
conn.on('close', () => {
|
|
164
|
-
if (!finished) {
|
|
165
|
-
this.emit('error', new PluginError(PLUGIN_NAME, 'SFTP abrupt closure'));
|
|
166
|
-
}
|
|
167
|
-
if (options.callback) {
|
|
168
|
-
options.callback();
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
conn.connect(connectionOptions);
|
|
172
|
-
}
|
|
173
|
-
function transform(file, encoding, callback) {
|
|
174
|
-
if (file.isNull()) {
|
|
175
|
-
return callback();
|
|
176
|
-
}
|
|
177
|
-
const finalRemotePath = normalizePath(node.path.join(remotePath, file.relative));
|
|
178
|
-
_pool.call(this, (sftp) => {
|
|
179
|
-
const dirname = node.path.dirname(finalRemotePath);
|
|
180
|
-
let fileDirs = parents(dirname)
|
|
181
|
-
.map((d) => d.replace(/^\/~/, '~'))
|
|
182
|
-
.map(normalizePath);
|
|
183
|
-
if (dirname.search(/^\//) === 0) {
|
|
184
|
-
fileDirs = fileDirs.map((dir) => dir.search(/^\//) === 0 ? dir : `/${dir}`);
|
|
185
|
-
}
|
|
186
|
-
fileDirs = fileDirs.filter((d) => d.length >= remotePath.length && !mkDirCache[d]);
|
|
187
|
-
async.whilst((cb) => cb(null, fileDirs && fileDirs.length), (cb) => {
|
|
188
|
-
let d = fileDirs.pop();
|
|
189
|
-
mkDirCache[d] = true;
|
|
190
|
-
if (remotePlatform &&
|
|
191
|
-
remotePlatform.toLowerCase().indexOf('win') !== -1) {
|
|
192
|
-
d = d.replace('/', '\\');
|
|
193
|
-
}
|
|
194
|
-
sftp.exists(d, (exist) => {
|
|
195
|
-
if (exist) {
|
|
196
|
-
cb();
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
const dirMode = options.dirMode || '0755';
|
|
200
|
-
sftp.mkdir(d, { mode: dirMode }, (err) => {
|
|
201
|
-
if (err) {
|
|
202
|
-
BalmJS.logger.warn(PLUGIN_NAME, `Error or directory exists: ${err} ${d}`);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
BalmJS.logger.debug(PLUGIN_NAME, `Created: ${d}`);
|
|
206
|
-
}
|
|
207
|
-
cb();
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}, () => {
|
|
212
|
-
const fileMode = options.fileMode || '0666';
|
|
213
|
-
const stream = sftp.createWriteStream(finalRemotePath, {
|
|
214
|
-
flags: 'w',
|
|
215
|
-
encoding: null,
|
|
216
|
-
mode: fileMode,
|
|
217
|
-
autoClose: true
|
|
218
|
-
});
|
|
219
|
-
if (file.isStream()) {
|
|
220
|
-
file.contents.pipe(stream);
|
|
221
|
-
}
|
|
222
|
-
else if (file.isBuffer()) {
|
|
223
|
-
stream.end(file.contents);
|
|
224
|
-
}
|
|
225
|
-
stream.on('close', function (error) {
|
|
226
|
-
if (error) {
|
|
227
|
-
this.emit('error', new PluginError(PLUGIN_NAME, error));
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
const fileRelativePath = file.relative;
|
|
231
|
-
BalmJS.logger.info(PLUGIN_NAME, `Uploaded: ${fileRelativePath} => ${finalRemotePath}`);
|
|
232
|
-
fileCount++;
|
|
233
|
-
}
|
|
234
|
-
return callback(error);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function flush(callback) {
|
|
240
|
-
if (fileCount > 0) {
|
|
241
|
-
const unit = fileCount === 1 ? 'file' : 'files';
|
|
242
|
-
BalmJS.logger.info(PLUGIN_NAME, `${fileCount} ${unit} uploaded successfully`);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
BalmJS.logger.warn(PLUGIN_NAME, 'No files uploaded');
|
|
246
|
-
}
|
|
247
|
-
finished = true;
|
|
248
|
-
if (sftpCache) {
|
|
249
|
-
sftpCache.end();
|
|
250
|
-
}
|
|
251
|
-
if (connCache) {
|
|
252
|
-
connCache.end();
|
|
253
|
-
}
|
|
254
|
-
callback();
|
|
255
|
-
}
|
|
256
|
-
return through2.obj(transform, flush);
|
|
257
|
-
}
|
|
258
|
-
export default gulpSftp;
|
package/tslib/tasks/default.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
class DefaultTask extends BalmJS.BalmTask {
|
|
2
|
-
constructor() {
|
|
3
|
-
super('default');
|
|
4
|
-
}
|
|
5
|
-
get startTask() {
|
|
6
|
-
const tasks = BalmJS.toNamespace(['start']);
|
|
7
|
-
if (BalmJS.utils.isString(BalmJS.beforeTask)) {
|
|
8
|
-
tasks.unshift(BalmJS.beforeTask);
|
|
9
|
-
}
|
|
10
|
-
return tasks;
|
|
11
|
-
}
|
|
12
|
-
get mainTasks() {
|
|
13
|
-
let tasks = [
|
|
14
|
-
'clean',
|
|
15
|
-
...(BalmJS.config.styles.sprites.length ? ['sprite'] : []),
|
|
16
|
-
'style',
|
|
17
|
-
...(BalmJS.config.scripts.lint ? ['lint'] : []),
|
|
18
|
-
'script',
|
|
19
|
-
'html',
|
|
20
|
-
...(BalmJS.config.env.isProd || !BalmJS.config.inFrontend
|
|
21
|
-
? ['image', 'font', 'media']
|
|
22
|
-
: [])
|
|
23
|
-
];
|
|
24
|
-
if (BalmJS.config.env.isProd) {
|
|
25
|
-
tasks = [
|
|
26
|
-
...tasks,
|
|
27
|
-
'extra',
|
|
28
|
-
'build',
|
|
29
|
-
...(BalmJS.config.assets.cache ? ['cache'] : []),
|
|
30
|
-
...(BalmJS.config.pwa.enabled ? ['workbox-sw', 'pwa'] : [])
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
tasks = [...tasks, 'modernizr', 'serve'];
|
|
35
|
-
}
|
|
36
|
-
let defaultMainTasks = BalmJS.config.useDefaults
|
|
37
|
-
? BalmJS.toNamespace(tasks)
|
|
38
|
-
: [];
|
|
39
|
-
if (BalmJS.config.env.inSSR ||
|
|
40
|
-
BalmJS.config.env.isMP ||
|
|
41
|
-
BalmJS.config.env.inDesktopApp) {
|
|
42
|
-
defaultMainTasks = BalmJS.toNamespace(BalmJS.config.env.isMP ? ['style', 'script'] : ['script']);
|
|
43
|
-
}
|
|
44
|
-
return defaultMainTasks;
|
|
45
|
-
}
|
|
46
|
-
get subTasks() {
|
|
47
|
-
return BalmJS.recipes.length
|
|
48
|
-
? BalmJS.toNamespace(BalmJS.recipes)
|
|
49
|
-
: [];
|
|
50
|
-
}
|
|
51
|
-
get endTask() {
|
|
52
|
-
const tasks = BalmJS.toNamespace(['end']);
|
|
53
|
-
if (BalmJS.utils.isString(BalmJS.afterTask)) {
|
|
54
|
-
tasks.push(BalmJS.afterTask);
|
|
55
|
-
}
|
|
56
|
-
return tasks;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export default DefaultTask;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
class BalmTask {
|
|
2
|
-
name;
|
|
3
|
-
taskName;
|
|
4
|
-
defaultInput = '';
|
|
5
|
-
defaultOutput = '';
|
|
6
|
-
input = '';
|
|
7
|
-
output = '';
|
|
8
|
-
customOptions = {};
|
|
9
|
-
gulpSrcOptions = {};
|
|
10
|
-
constructor(name) {
|
|
11
|
-
this.name = name;
|
|
12
|
-
this.taskName = BalmJS.toNamespace(name);
|
|
13
|
-
}
|
|
14
|
-
get styleName() {
|
|
15
|
-
let name;
|
|
16
|
-
switch (BalmJS.config.styles.extname) {
|
|
17
|
-
case 'sass':
|
|
18
|
-
case 'scss':
|
|
19
|
-
name = 'sass';
|
|
20
|
-
break;
|
|
21
|
-
case 'less':
|
|
22
|
-
name = 'less';
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
name = 'postcss';
|
|
26
|
-
}
|
|
27
|
-
return name;
|
|
28
|
-
}
|
|
29
|
-
get src() {
|
|
30
|
-
return gulp
|
|
31
|
-
.src(this.input, Object.assign({
|
|
32
|
-
allowEmpty: true,
|
|
33
|
-
encoding: false
|
|
34
|
-
}, this.gulpSrcOptions))
|
|
35
|
-
.pipe(BalmJS.plugins.plumber((error) => {
|
|
36
|
-
BalmJS.logger.error(`${this.name} task`, error.message);
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
init(input, output, options = {}) {
|
|
40
|
-
let key = this.name;
|
|
41
|
-
switch (key) {
|
|
42
|
-
case 'copy':
|
|
43
|
-
key = 'rename';
|
|
44
|
-
break;
|
|
45
|
-
case 'jsmin':
|
|
46
|
-
key = 'terser';
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
}
|
|
50
|
-
const useAbsPath = !['webpack', 'rollup', 'esbuild', 'sprite'].includes(key);
|
|
51
|
-
this.input = useAbsPath && (input || this.defaultInput)
|
|
52
|
-
? BalmJS.file.absPaths(input || this.defaultInput)
|
|
53
|
-
: input || this.defaultInput;
|
|
54
|
-
this.output = useAbsPath && typeof (output || this.defaultOutput) === 'string'
|
|
55
|
-
? BalmJS.file.absPath(output || this.defaultOutput)
|
|
56
|
-
: output || this.defaultOutput;
|
|
57
|
-
this.customOptions = options[key] || {};
|
|
58
|
-
const obj = {
|
|
59
|
-
input: this.input,
|
|
60
|
-
output: this.output
|
|
61
|
-
};
|
|
62
|
-
if (options[key]) {
|
|
63
|
-
obj.customOptions = this.customOptions;
|
|
64
|
-
}
|
|
65
|
-
if (useAbsPath) {
|
|
66
|
-
BalmJS.logger.debug(`${this.name} task`, obj, {
|
|
67
|
-
pre: true
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (options.src) {
|
|
71
|
-
this.gulpSrcOptions = options.src;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export default BalmTask;
|
|
@@ -1,68 +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
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
if (BalmJS.config.styles.entry) {
|
|
22
|
-
this.defaultInput = node.path.join(BalmJS.config.src.css, BalmJS.config.styles.entry);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
this.defaultInput = node.path.join(BalmJS.config.src.css, '**', `!(_*).${extname}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
this.defaultOutput = BalmJS.config.env.isMP
|
|
29
|
-
? node.path.join(BalmJS.config.dest.base, ASSET.mpDir, BalmJS.config.paths.target.css)
|
|
30
|
-
: BalmJS.config.dest.css;
|
|
31
|
-
}
|
|
32
|
-
handleStyle(style, output, options) {
|
|
33
|
-
BalmJS.logger.debug(`${this.name} entry`, this.defaultInput, {
|
|
34
|
-
pre: true
|
|
35
|
-
});
|
|
36
|
-
const taskName = `${this.name} task`;
|
|
37
|
-
const shouldUseSourceMap = !(BalmJS.config.env.isProd || BalmJS.config.styles.minify);
|
|
38
|
-
let stream = gulp
|
|
39
|
-
.src(this.input, Object.assign({
|
|
40
|
-
sourcemaps: shouldUseSourceMap,
|
|
41
|
-
allowEmpty: true
|
|
42
|
-
}, this.gulpSrcOptions))
|
|
43
|
-
.pipe(BalmJS.plugins.plumber(function (error) {
|
|
44
|
-
BalmJS.logger.error(taskName, error.message);
|
|
45
|
-
this.emit('end');
|
|
46
|
-
this.destroy();
|
|
47
|
-
}));
|
|
48
|
-
switch (style) {
|
|
49
|
-
case 'sass':
|
|
50
|
-
stream = stream.pipe(node.isLegacySass
|
|
51
|
-
? BalmJS.plugins.legacySass(options)
|
|
52
|
-
: BalmJS.plugins.sass(options));
|
|
53
|
-
break;
|
|
54
|
-
case 'less':
|
|
55
|
-
stream = stream.pipe(BalmJS.plugins.less(options));
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
}
|
|
59
|
-
return stream
|
|
60
|
-
.pipe(BalmJS.plugins.postcss(BalmJS.plugins.postcssPlugins(style === 'postcss')))
|
|
61
|
-
.pipe($.if(BalmJS.config.env.isMP, BalmJS.plugins.rename({ extname: '.wxss' })))
|
|
62
|
-
.pipe(gulp.dest(output, {
|
|
63
|
-
sourcemaps: shouldUseSourceMap
|
|
64
|
-
}))
|
|
65
|
-
.pipe(server.reload({ stream: true }));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
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();
|
|
6
|
-
BalmJS.recipes = [];
|
|
7
|
-
BalmJS.recipeIndex = 0;
|
|
8
|
-
BalmJS.server = null;
|
|
9
|
-
BalmJS.watchFtpFile = '';
|
|
10
|
-
BalmJS.watching = false;
|