balm-core 3.26.3 → 3.28.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 -22
- package/lib/bootstrap/check_config.js +4 -10
- package/lib/bootstrap/index.js +17 -28
- package/lib/bundler/esbuild/build.js +0 -4
- package/lib/bundler/esbuild/index.js +0 -5
- package/lib/bundler/esbuild/transform.js +0 -33
- package/lib/bundler/rollup/build.js +2 -17
- package/lib/bundler/rollup/entry.js +2 -6
- package/lib/bundler/rollup/index.js +0 -32
- package/lib/bundler/rollup/output.js +0 -6
- package/lib/bundler/rollup/plugins.js +0 -11
- package/lib/bundler/webpack/config/common.js +3 -26
- package/lib/bundler/webpack/config/dev.js +2 -6
- package/lib/bundler/webpack/config/index.js +0 -5
- package/lib/bundler/webpack/config/prod.js +2 -17
- package/lib/bundler/webpack/entry.js +12 -23
- package/lib/bundler/webpack/index.js +5 -14
- package/lib/bundler/webpack/loaders.js +0 -10
- package/lib/bundler/webpack/output.js +0 -7
- package/lib/bundler/webpack/rules/babel.js +3 -7
- package/lib/bundler/webpack/rules/css.js +2 -7
- package/lib/bundler/webpack/rules/html.js +0 -3
- package/lib/bundler/webpack/rules/url.js +2 -6
- package/lib/config/assets.js +0 -5
- package/lib/config/env.js +0 -2
- package/lib/config/globals.js +3 -10
- package/lib/config/html.js +0 -1
- package/lib/config/index.js +0 -21
- package/lib/config/logs.js +0 -1
- package/lib/config/paths.js +2 -3
- package/lib/config/pwa.js +0 -3
- package/lib/config/roots.js +0 -3
- package/lib/config/scripts.js +24 -32
- package/lib/config/server.js +4 -11
- package/lib/config/styles.js +2 -10
- package/lib/config/version.js +0 -3
- package/lib/hello.js +0 -5
- package/lib/hooks/index.js +20 -27
- package/lib/hooks/maker.js +2 -22
- package/lib/index.js +0 -5
- package/lib/middlewares/history.js +0 -3
- package/lib/middlewares/index.js +0 -9
- package/lib/middlewares/proxy.js +1 -9
- package/lib/middlewares/webpack.js +0 -6
- package/lib/plugins/htmlmin.js +1 -7
- package/lib/plugins/imagemin.js +1 -29
- package/lib/plugins/index.js +0 -12
- package/lib/plugins/jsmin.js +0 -20
- package/lib/plugins/less.js +7 -19
- package/lib/plugins/plumber.js +5 -24
- package/lib/plugins/postcss-plugins.js +0 -9
- package/lib/plugins/postcss.js +9 -27
- package/lib/plugins/rename.js +3 -16
- package/lib/plugins/replace.js +4 -26
- package/lib/plugins/sass.js +31 -45
- package/lib/plugins/sftp.js +36 -69
- package/lib/tasks/default.js +2 -23
- package/lib/tasks/foundation/balm.js +0 -19
- package/lib/tasks/foundation/balm_style.js +2 -27
- package/lib/tasks/foundation/index.js +0 -5
- package/lib/tasks/index.js +7 -16
- package/lib/tasks/private/build.js +0 -17
- package/lib/tasks/private/cache.js +0 -19
- package/lib/tasks/private/clean.js +0 -33
- package/lib/tasks/private/end.js +0 -23
- package/lib/tasks/private/extra.js +4 -29
- package/lib/tasks/private/font.js +0 -17
- package/lib/tasks/private/image.js +1 -28
- package/lib/tasks/private/lint.js +0 -17
- package/lib/tasks/private/media.js +0 -17
- package/lib/tasks/private/modernizr.js +0 -39
- package/lib/tasks/private/pwa-cache.js +0 -21
- package/lib/tasks/private/script.js +0 -13
- package/lib/tasks/private/sprite.js +3 -37
- package/lib/tasks/private/start.js +0 -23
- package/lib/tasks/private/style.js +0 -14
- package/lib/tasks/private/workbox-sw.js +0 -17
- package/lib/tasks/public/copy.js +0 -17
- package/lib/tasks/public/esbuild.js +0 -19
- package/lib/tasks/public/ftp.js +1 -22
- package/lib/tasks/public/html.js +0 -31
- package/lib/tasks/public/jsmin.js +0 -17
- package/lib/tasks/public/less.js +0 -17
- package/lib/tasks/public/postcss.js +0 -16
- package/lib/tasks/public/publish.js +3 -29
- package/lib/tasks/public/pwa.js +1 -30
- package/lib/tasks/public/remove.js +2 -34
- package/lib/tasks/public/replace.js +0 -18
- package/lib/tasks/public/rollup.js +0 -20
- package/lib/tasks/public/sass.js +0 -17
- package/lib/tasks/public/server.js +5 -44
- package/lib/tasks/public/url.js +0 -24
- package/lib/tasks/public/version.js +0 -17
- package/lib/tasks/public/webpack.js +2 -27
- package/lib/tasks/public/zip.js +0 -18
- package/lib/utilities/address.js +5 -21
- package/lib/utilities/cache-core.js +5 -21
- package/lib/utilities/color.js +0 -8
- package/lib/utilities/compiling.js +0 -15
- package/lib/utilities/detect-port.js +6 -26
- package/lib/utilities/escape-string-regexp.js +3 -5
- package/lib/utilities/file.js +3 -23
- package/lib/utilities/index.js +0 -5
- package/lib/utilities/loading.js +0 -23
- package/lib/utilities/logger.js +0 -21
- package/lib/utilities/merge-stream.js +0 -11
- package/lib/utilities/namespace.js +0 -4
- package/lib/utilities/public-url.js +9 -12
- package/lib/utilities/replacestream.js +5 -31
- package/lib/utilities/typeof.js +0 -2
- package/lib/utilities/utils.js +2 -12
- package/package.json +12 -12
- package/tslib/bundler/esbuild/transform.js +26 -19
- package/tslib/bundler/rollup/index.js +12 -5
package/lib/plugins/plumber.js
CHANGED
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
exports.stop = stop;
|
|
8
|
-
|
|
9
8
|
var _events = require("events");
|
|
10
|
-
|
|
11
9
|
// Reference `gulp-plumber@1.2.1`
|
|
10
|
+
|
|
12
11
|
var PLUGIN_NAME = 'plumber';
|
|
13
12
|
var emitter = new _events.EventEmitter();
|
|
14
|
-
|
|
15
13
|
function removeDefaultHandler(stream, event) {
|
|
16
14
|
var found = false;
|
|
17
15
|
stream.listeners(event).forEach(function (item) {
|
|
@@ -22,10 +20,8 @@ function removeDefaultHandler(stream, event) {
|
|
|
22
20
|
}, stream);
|
|
23
21
|
return found;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
function wrapPanicOnErrorHandler(stream) {
|
|
27
24
|
var oldHandler = removeDefaultHandler(stream, 'error');
|
|
28
|
-
|
|
29
25
|
if (oldHandler) {
|
|
30
26
|
stream.on('error', function onerror2(error) {
|
|
31
27
|
if (emitter.listenerCount('error') === 1) {
|
|
@@ -35,30 +31,24 @@ function wrapPanicOnErrorHandler(stream) {
|
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
function defaultErrorHandler(error) {
|
|
40
35
|
// onerror2 and this handler
|
|
41
36
|
if (emitter.listenerCount('error') < 3) {
|
|
42
37
|
BalmJS.logger.error("".concat(PLUGIN_NAME, " - found unhandled error"), error.toString());
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
|
|
46
40
|
function gulpPlumber() {
|
|
47
41
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
48
|
-
|
|
49
42
|
if (BalmJS.utils.isFunction(opts)) {
|
|
50
43
|
opts = {
|
|
51
44
|
errorHandler: opts
|
|
52
45
|
};
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
var through = through2.obj();
|
|
56
48
|
through._plumber = true;
|
|
57
|
-
|
|
58
49
|
if (opts.errorHandler !== false) {
|
|
59
50
|
through.errorHandler = BalmJS.utils.isFunction(opts.errorHandler) ? opts.errorHandler : defaultErrorHandler;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
function patchPipe(stream) {
|
|
63
53
|
if (stream.pipe2) {
|
|
64
54
|
wrapPanicOnErrorHandler(stream);
|
|
@@ -67,49 +57,40 @@ function gulpPlumber() {
|
|
|
67
57
|
stream._plumbed = true;
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
|
-
|
|
71
60
|
through.pipe2 = function pipe2(dest) {
|
|
72
61
|
if (!dest) {
|
|
73
62
|
throw new PluginError(PLUGIN_NAME, "Can't pipe to undefined");
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
this._pipe(dest);
|
|
77
|
-
|
|
78
65
|
if (dest._unplumbed) {
|
|
79
66
|
return dest;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
removeDefaultHandler(this, 'error');
|
|
83
|
-
|
|
84
69
|
if (dest._plumber) {
|
|
85
70
|
return dest;
|
|
86
71
|
}
|
|
72
|
+
dest.pipe2 = pipe2;
|
|
87
73
|
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
// Patching pipe method
|
|
90
75
|
if (opts.inherit !== false) {
|
|
91
76
|
patchPipe(dest);
|
|
92
|
-
}
|
|
93
|
-
|
|
77
|
+
}
|
|
94
78
|
|
|
79
|
+
// Placing custom on error handler
|
|
95
80
|
if (this.errorHandler) {
|
|
96
81
|
dest.errorHandler = this.errorHandler;
|
|
97
82
|
dest.on('error', this.errorHandler.bind(dest));
|
|
98
83
|
}
|
|
99
|
-
|
|
100
84
|
dest._plumbed = true;
|
|
101
85
|
return dest;
|
|
102
86
|
};
|
|
103
|
-
|
|
104
87
|
patchPipe(through);
|
|
105
88
|
return through;
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
function stop() {
|
|
109
91
|
var through = through2.obj();
|
|
110
92
|
through._unplumbed = true;
|
|
111
93
|
return through;
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
var _default = gulpPlumber;
|
|
115
96
|
exports["default"] = _default;
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
9
|
function getDefaultPostcssPlugins() {
|
|
13
10
|
var isPostCSS = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
14
|
-
|
|
15
11
|
var postcssPresetEnv = require('postcss-preset-env');
|
|
16
|
-
|
|
17
12
|
var atImport = require('postcss-import');
|
|
18
|
-
|
|
19
13
|
var autoprefixer = require('autoprefixer');
|
|
20
|
-
|
|
21
14
|
var cssnano = require('cssnano');
|
|
22
|
-
|
|
23
15
|
var defaultPostcssPlugins = isPostCSS || BalmJS.config.styles.extname === 'css' ? [postcssPresetEnv(BalmJS.config.styles.postcssEnvOptions), atImport({
|
|
24
16
|
path: BalmJS.file.stylePaths
|
|
25
17
|
})] : [];
|
|
@@ -28,6 +20,5 @@ function getDefaultPostcssPlugins() {
|
|
|
28
20
|
}))] : [];
|
|
29
21
|
return defaultPostcssPlugins.concat([autoprefixer()].concat(cssnanoPlugin, (0, _toConsumableArray2["default"])(BalmJS.config.styles.postcssPlugins)));
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
var _default = getDefaultPostcssPlugins;
|
|
33
24
|
exports["default"] = _default;
|
package/lib/plugins/postcss.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _stream = require("stream");
|
|
11
|
-
|
|
12
9
|
var _vinylSourcemapsApply = _interopRequireDefault(require("vinyl-sourcemaps-apply"));
|
|
13
|
-
|
|
14
10
|
// Reference `gulp-postcss@9.0.1`
|
|
15
|
-
var PLUGIN_NAME = 'postcss';
|
|
16
11
|
|
|
12
|
+
var PLUGIN_NAME = 'postcss';
|
|
17
13
|
function gulpPostcss(cb) {
|
|
18
14
|
return function (plugins, options) {
|
|
19
15
|
if (Array.isArray(plugins)) {
|
|
@@ -29,11 +25,9 @@ function gulpPostcss(cb) {
|
|
|
29
25
|
});
|
|
30
26
|
} else {
|
|
31
27
|
var postcssLoadConfig = require('postcss-load-config');
|
|
32
|
-
|
|
33
28
|
var contextOptions = plugins || {};
|
|
34
29
|
return cb(function (file) {
|
|
35
30
|
var configPath;
|
|
36
|
-
|
|
37
31
|
if (contextOptions.config) {
|
|
38
32
|
if (path.isAbsolute(contextOptions.config)) {
|
|
39
33
|
configPath = contextOptions.config;
|
|
@@ -43,7 +37,6 @@ function gulpPostcss(cb) {
|
|
|
43
37
|
} else {
|
|
44
38
|
configPath = file.dirname;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
return postcssLoadConfig({
|
|
48
41
|
file: file,
|
|
49
42
|
options: contextOptions
|
|
@@ -52,22 +45,19 @@ function gulpPostcss(cb) {
|
|
|
52
45
|
}
|
|
53
46
|
};
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
var _default = gulpPostcss(function (loadConfig) {
|
|
57
49
|
var stream = new _stream.Transform({
|
|
58
50
|
objectMode: true
|
|
59
51
|
});
|
|
60
|
-
|
|
61
52
|
stream._transform = function (file, encoding, cb) {
|
|
62
53
|
if (file.isNull()) {
|
|
63
54
|
return cb(null, file);
|
|
64
55
|
}
|
|
65
|
-
|
|
66
56
|
if (file.isStream()) {
|
|
67
57
|
return handleError('Streams are not supported!');
|
|
68
|
-
}
|
|
69
|
-
|
|
58
|
+
}
|
|
70
59
|
|
|
60
|
+
// Protect `from` and `map` if using gulp-sourcemaps
|
|
71
61
|
var isProtected = file.sourceMap ? {
|
|
72
62
|
from: true,
|
|
73
63
|
map: true
|
|
@@ -81,8 +71,8 @@ var _default = gulpPostcss(function (loadConfig) {
|
|
|
81
71
|
} : false
|
|
82
72
|
};
|
|
83
73
|
loadConfig(file).then(function (config) {
|
|
84
|
-
var configOpts = config.options || {};
|
|
85
|
-
|
|
74
|
+
var configOpts = config.options || {};
|
|
75
|
+
// Extend the default options if not protected
|
|
86
76
|
for (var opt in configOpts) {
|
|
87
77
|
if (Object.prototype.hasOwnProperty.call(configOpts, opt) && !isProtected[opt]) {
|
|
88
78
|
options[opt] = configOpts[opt];
|
|
@@ -90,15 +80,14 @@ var _default = gulpPostcss(function (loadConfig) {
|
|
|
90
80
|
BalmJS.logger.info(PLUGIN_NAME, "".concat(file.relative, "\nCannot override ").concat(opt, " option, because it is required by gulp-sourcemaps"));
|
|
91
81
|
}
|
|
92
82
|
}
|
|
93
|
-
|
|
94
83
|
return require('postcss')(config.plugins || []).process(file.contents, options);
|
|
95
84
|
}).then(handleResult, handleError);
|
|
96
|
-
|
|
97
85
|
function handleResult(result) {
|
|
98
86
|
var map;
|
|
99
87
|
var warnings = result.warnings().join('\n');
|
|
100
|
-
file.contents = Buffer.from(result.css);
|
|
88
|
+
file.contents = Buffer.from(result.css);
|
|
101
89
|
|
|
90
|
+
// Apply source map to the chain
|
|
102
91
|
if (file.sourceMap) {
|
|
103
92
|
map = result.map.toJSON();
|
|
104
93
|
map.file = file.relative;
|
|
@@ -107,22 +96,18 @@ var _default = gulpPostcss(function (loadConfig) {
|
|
|
107
96
|
});
|
|
108
97
|
(0, _vinylSourcemapsApply["default"])(file, map);
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
if (warnings) {
|
|
112
100
|
BalmJS.logger.info(PLUGIN_NAME, "".concat(file.relative, "\nwarnings"));
|
|
113
101
|
}
|
|
114
|
-
|
|
115
102
|
setImmediate(function () {
|
|
116
103
|
cb(null, file);
|
|
117
104
|
});
|
|
118
105
|
}
|
|
119
|
-
|
|
120
106
|
function handleError(error) {
|
|
121
107
|
var errorOptions = {
|
|
122
108
|
fileName: file.path,
|
|
123
109
|
showStack: true
|
|
124
110
|
};
|
|
125
|
-
|
|
126
111
|
if (error.name === 'CssSyntaxError') {
|
|
127
112
|
errorOptions.error = error;
|
|
128
113
|
errorOptions.fileName = error.file || file.path;
|
|
@@ -130,17 +115,14 @@ var _default = gulpPostcss(function (loadConfig) {
|
|
|
130
115
|
errorOptions.showProperties = false;
|
|
131
116
|
errorOptions.showStack = false;
|
|
132
117
|
error = "".concat(error.message, "\n\n").concat(error.showSourceCode(), "\n");
|
|
133
|
-
}
|
|
118
|
+
}
|
|
119
|
+
// Prevent stream’s unhandled exception from
|
|
134
120
|
// being suppressed by Promise
|
|
135
|
-
|
|
136
|
-
|
|
137
121
|
setImmediate(function () {
|
|
138
122
|
cb(new PluginError('gulp-postcss', error, errorOptions));
|
|
139
123
|
});
|
|
140
124
|
}
|
|
141
125
|
};
|
|
142
|
-
|
|
143
126
|
return stream;
|
|
144
127
|
});
|
|
145
|
-
|
|
146
128
|
exports["default"] = _default;
|
package/lib/plugins/rename.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
9
|
var _stream = require("stream");
|
|
13
|
-
|
|
14
10
|
// Reference `gulp-rename@2.0.0`
|
|
11
|
+
|
|
15
12
|
function gulpRename(obj) {
|
|
16
13
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17
14
|
var stream = new _stream.Transform({
|
|
18
15
|
objectMode: true
|
|
19
16
|
});
|
|
20
|
-
|
|
21
17
|
var parsePath = function parsePath(_path) {
|
|
22
18
|
var extname = options.multiExt ? path.basename(_path).slice(path.basename(_path).indexOf('.')) : path.extname(_path);
|
|
23
19
|
return {
|
|
@@ -26,26 +22,20 @@ function gulpRename(obj) {
|
|
|
26
22
|
extname: extname
|
|
27
23
|
};
|
|
28
24
|
};
|
|
29
|
-
|
|
30
25
|
stream._transform = function (chunk, unused, callback) {
|
|
31
26
|
var file = chunk.clone({
|
|
32
27
|
contents: false
|
|
33
28
|
});
|
|
34
29
|
var parsedPath = parsePath(file.relative);
|
|
35
|
-
|
|
36
30
|
var _path;
|
|
37
|
-
|
|
38
31
|
var type = (0, _typeof2["default"])(obj);
|
|
39
|
-
|
|
40
32
|
if (type === 'string' && obj !== '') {
|
|
41
33
|
_path = obj;
|
|
42
34
|
} else if (type === 'function') {
|
|
43
35
|
var newParsedPath = obj(parsedPath, file);
|
|
44
|
-
|
|
45
36
|
if ((0, _typeof2["default"])(newParsedPath) === 'object' && newParsedPath !== null) {
|
|
46
37
|
parsedPath = newParsedPath;
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
_path = path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
|
|
50
40
|
} else if (type === 'object' && obj !== undefined && obj !== null) {
|
|
51
41
|
var _obj = obj;
|
|
@@ -60,18 +50,15 @@ function gulpRename(obj) {
|
|
|
60
50
|
callback(new Error('Unsupported renaming parameter type supplied'), undefined);
|
|
61
51
|
return;
|
|
62
52
|
}
|
|
53
|
+
file.path = path.join(file.base, _path);
|
|
63
54
|
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
// Rename sourcemap if present
|
|
66
56
|
if (file.sourceMap) {
|
|
67
57
|
file.sourceMap.file = file.relative;
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
callback(null, file);
|
|
71
60
|
};
|
|
72
|
-
|
|
73
61
|
return stream;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
var _default = gulpRename;
|
|
77
64
|
exports["default"] = _default;
|
package/lib/plugins/replace.js
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _stream = require("stream");
|
|
13
|
-
|
|
14
10
|
var _replacestream = _interopRequireDefault(require("../utilities/replacestream"));
|
|
15
|
-
|
|
16
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
13
|
var defaultOptions = {
|
|
21
14
|
skipBinary: true
|
|
22
15
|
};
|
|
23
|
-
|
|
24
16
|
function gulpReplace(search, _replacement) {
|
|
25
17
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
26
18
|
// merge options
|
|
27
19
|
options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
28
20
|
return new _stream.Transform({
|
|
29
21
|
objectMode: true,
|
|
30
|
-
|
|
31
22
|
/**
|
|
32
23
|
* transformation
|
|
33
24
|
* @param {import("vinyl")} file
|
|
@@ -38,62 +29,52 @@ function gulpReplace(search, _replacement) {
|
|
|
38
29
|
if (file.isNull()) {
|
|
39
30
|
return callback(null, file);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
var replacement = _replacement;
|
|
43
|
-
|
|
44
33
|
if (typeof _replacement === 'function') {
|
|
45
34
|
// Pass the vinyl file object as this.file
|
|
46
35
|
replacement = _replacement.bind({
|
|
47
36
|
file: file
|
|
48
37
|
});
|
|
49
38
|
}
|
|
50
|
-
|
|
51
39
|
function doReplace() {
|
|
52
40
|
if (file.isStream()) {
|
|
53
41
|
file.contents = file.contents.pipe((0, _replacestream["default"])(search, replacement));
|
|
54
42
|
return callback(null, file);
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
if (file.isBuffer()) {
|
|
58
45
|
var content = file.contents.toString();
|
|
59
|
-
|
|
60
46
|
if (search instanceof RegExp) {
|
|
61
47
|
file.contents = Buffer.from(content.replace(search, replacement));
|
|
62
48
|
} else {
|
|
63
49
|
var chunks = content.split(search);
|
|
64
50
|
var result;
|
|
65
|
-
|
|
66
51
|
if (typeof replacement === 'function') {
|
|
67
52
|
// Start with the first chunk already in the result
|
|
68
53
|
// Replacements will be added thereafter
|
|
69
54
|
// This is done to avoid checking the value of i in the loop
|
|
70
|
-
result = [chunks[0]];
|
|
55
|
+
result = [chunks[0]];
|
|
71
56
|
|
|
57
|
+
// The replacement function should be called once for each match
|
|
72
58
|
for (var i = 1; i < chunks.length; i++) {
|
|
73
59
|
// Add the replacement value
|
|
74
|
-
result.push(replacement(search));
|
|
60
|
+
result.push(replacement(search));
|
|
75
61
|
|
|
62
|
+
// Add the next chunk
|
|
76
63
|
result.push(chunks[i]);
|
|
77
64
|
}
|
|
78
|
-
|
|
79
65
|
result = result.join('');
|
|
80
66
|
} else {
|
|
81
67
|
result = chunks.join(replacement);
|
|
82
68
|
}
|
|
83
|
-
|
|
84
69
|
file.contents = Buffer.from(result);
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
return callback(null, file);
|
|
88
72
|
}
|
|
89
|
-
|
|
90
73
|
callback(null, file);
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
if (options.skipBinary) {
|
|
94
76
|
// fix@istextorbinary: "editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening."
|
|
95
77
|
var isNode16 = process.version.split('.')[0] === 'v16';
|
|
96
|
-
|
|
97
78
|
if (isNode16) {
|
|
98
79
|
doReplace();
|
|
99
80
|
} else {
|
|
@@ -103,14 +84,11 @@ function gulpReplace(search, _replacement) {
|
|
|
103
84
|
callback(null, file);
|
|
104
85
|
}
|
|
105
86
|
}
|
|
106
|
-
|
|
107
87
|
return;
|
|
108
88
|
}
|
|
109
|
-
|
|
110
89
|
doReplace();
|
|
111
90
|
}
|
|
112
91
|
});
|
|
113
92
|
}
|
|
114
|
-
|
|
115
93
|
var _default = gulpReplace;
|
|
116
94
|
exports["default"] = _default;
|
package/lib/plugins/sass.js
CHANGED
|
@@ -1,78 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _stream = require("stream");
|
|
11
|
-
|
|
12
9
|
var _sass = _interopRequireDefault(require("sass"));
|
|
13
|
-
|
|
14
10
|
var _replaceExt = _interopRequireDefault(require("replace-ext"));
|
|
15
|
-
|
|
16
11
|
var _vinylSourcemapsApply = _interopRequireDefault(require("vinyl-sourcemaps-apply"));
|
|
17
|
-
|
|
18
12
|
// Reference `gulp-sass@5.1.0`
|
|
19
|
-
var PLUGIN_NAME = 'sass';
|
|
20
13
|
|
|
14
|
+
var PLUGIN_NAME = 'sass';
|
|
21
15
|
var transformObj = function transformObj(transform) {
|
|
22
16
|
return new _stream.Transform({
|
|
23
17
|
transform: transform,
|
|
24
18
|
objectMode: true
|
|
25
19
|
});
|
|
26
20
|
};
|
|
21
|
+
|
|
27
22
|
/**
|
|
28
23
|
* Handles returning the file to the stream
|
|
29
24
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
25
|
var filePush = function filePush(file, sassObject, callback) {
|
|
33
26
|
// Build Source Maps!
|
|
34
27
|
if (sassObject.map) {
|
|
35
28
|
// Transform map into JSON
|
|
36
|
-
var sassMap = JSON.parse(sassObject.map.toString());
|
|
37
|
-
|
|
38
|
-
var sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
39
|
-
|
|
40
|
-
var sassFileSrc = file.relative;
|
|
41
|
-
|
|
29
|
+
var sassMap = JSON.parse(sassObject.map.toString());
|
|
30
|
+
// Grab the stdout and transform it into stdin
|
|
31
|
+
var sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
32
|
+
// Grab the base filename that's being worked on
|
|
33
|
+
var sassFileSrc = file.relative;
|
|
34
|
+
// Grab the path portion of the file that's being worked on
|
|
42
35
|
var sassFileSrcPath = path.dirname(sassFileSrc);
|
|
43
|
-
|
|
44
36
|
if (sassFileSrcPath) {
|
|
45
|
-
var sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
46
|
-
|
|
37
|
+
var sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
38
|
+
// Prepend the path to all files in the sources array except the file that's being worked on
|
|
47
39
|
sassMap.sources = sassMap.sources.map(function (source, index) {
|
|
48
40
|
return index === sourceFileIndex ? source : path.join(sassFileSrcPath, source);
|
|
49
41
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
42
|
+
}
|
|
52
43
|
|
|
44
|
+
// Remove 'stdin' from sources and replace with filenames!
|
|
53
45
|
sassMap.sources = sassMap.sources.filter(function (src) {
|
|
54
46
|
return src !== 'stdin' && src;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
sassMap.file = (0, _replaceExt["default"])(sassFileSrc, '.css'); // Apply the map
|
|
47
|
+
});
|
|
58
48
|
|
|
49
|
+
// Replace the map file with the original filename (but new extension)
|
|
50
|
+
sassMap.file = (0, _replaceExt["default"])(sassFileSrc, '.css');
|
|
51
|
+
// Apply the map
|
|
59
52
|
(0, _vinylSourcemapsApply["default"])(file, sassMap);
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
file.contents = sassObject.css;
|
|
63
55
|
file.path = (0, _replaceExt["default"])(file.path, '.css');
|
|
64
|
-
|
|
65
56
|
if (file.stat) {
|
|
66
57
|
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
callback(null, file);
|
|
70
60
|
};
|
|
61
|
+
|
|
71
62
|
/**
|
|
72
63
|
* Handles error message
|
|
73
64
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
65
|
var handleError = function handleError(error, file, callback) {
|
|
77
66
|
var filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
78
67
|
var relativePath = path.relative(process.cwd(), filePath);
|
|
@@ -82,44 +71,42 @@ var handleError = function handleError(error, file, callback) {
|
|
|
82
71
|
error.message = require('strip-ansi')(message);
|
|
83
72
|
error.relativePath = relativePath;
|
|
84
73
|
return callback(new PluginError(PLUGIN_NAME, error));
|
|
85
|
-
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//////////////////////////////
|
|
86
77
|
// Main Gulp Sass function
|
|
87
78
|
//////////////////////////////
|
|
88
|
-
|
|
89
|
-
|
|
90
79
|
var gulpSass = function gulpSass(options) {
|
|
91
80
|
return transformObj(function (file, encoding, callback) {
|
|
92
81
|
if (file.isNull()) {
|
|
93
82
|
callback(null, file);
|
|
94
83
|
return;
|
|
95
84
|
}
|
|
96
|
-
|
|
97
85
|
if (file.isStream()) {
|
|
98
86
|
callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
99
87
|
return;
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
if (path.basename(file.path).startsWith('_')) {
|
|
103
90
|
callback();
|
|
104
91
|
return;
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
if (!file.contents.length) {
|
|
108
94
|
file.path = (0, _replaceExt["default"])(file.path, '.css');
|
|
109
95
|
callback(null, file);
|
|
110
96
|
return;
|
|
111
97
|
}
|
|
112
|
-
|
|
113
98
|
var opts = options || {};
|
|
114
|
-
opts.data = file.contents.toString();
|
|
99
|
+
opts.data = file.contents.toString();
|
|
115
100
|
|
|
116
|
-
|
|
101
|
+
// We set the file path here so that libsass can correctly resolve import paths
|
|
102
|
+
opts.file = file.path;
|
|
117
103
|
|
|
104
|
+
// Ensure `indentedSyntax` is true if a `.sass` file
|
|
118
105
|
if (path.extname(file.path) === '.sass') {
|
|
119
106
|
opts.indentedSyntax = true;
|
|
120
|
-
}
|
|
121
|
-
|
|
107
|
+
}
|
|
122
108
|
|
|
109
|
+
// Ensure file's parent directory in the include path
|
|
123
110
|
if (opts.includePaths) {
|
|
124
111
|
if (typeof opts.includePaths === 'string') {
|
|
125
112
|
opts.includePaths = [opts.includePaths];
|
|
@@ -127,18 +114,18 @@ var gulpSass = function gulpSass(options) {
|
|
|
127
114
|
} else {
|
|
128
115
|
opts.includePaths = [];
|
|
129
116
|
}
|
|
117
|
+
opts.includePaths.unshift(path.dirname(file.path));
|
|
130
118
|
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
// Generate Source Maps if the source-map plugin is present
|
|
133
120
|
if (file.sourceMap) {
|
|
134
121
|
opts.sourceMap = file.path;
|
|
135
122
|
opts.omitSourceMapUrl = true;
|
|
136
123
|
opts.sourceMapContents = true;
|
|
137
|
-
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//////////////////////////////
|
|
138
127
|
// Sync Sass render
|
|
139
128
|
//////////////////////////////
|
|
140
|
-
|
|
141
|
-
|
|
142
129
|
try {
|
|
143
130
|
gulpSass.compiler && filePush(file, gulpSass.compiler.renderSync(opts), callback);
|
|
144
131
|
} catch (error) {
|
|
@@ -146,7 +133,6 @@ var gulpSass = function gulpSass(options) {
|
|
|
146
133
|
}
|
|
147
134
|
});
|
|
148
135
|
};
|
|
149
|
-
|
|
150
136
|
gulpSass.compiler = _sass["default"];
|
|
151
137
|
var _default = gulpSass;
|
|
152
138
|
exports["default"] = _default;
|