balm-core 4.11.0 → 4.13.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 +31 -31
package/lib/plugins/postcss.js
CHANGED
|
@@ -4,7 +4,6 @@ import postcss from 'postcss';
|
|
|
4
4
|
import postcssLoadConfig from 'postcss-load-config';
|
|
5
5
|
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
6
6
|
const PLUGIN_NAME = 'postcss';
|
|
7
|
-
|
|
8
7
|
function gulpPostcss(cb) {
|
|
9
8
|
return function (plugins, options) {
|
|
10
9
|
if (Array.isArray(plugins)) {
|
|
@@ -18,7 +17,6 @@ function gulpPostcss(cb) {
|
|
|
18
17
|
const contextOptions = plugins || {};
|
|
19
18
|
return cb(file => {
|
|
20
19
|
let configPath;
|
|
21
|
-
|
|
22
20
|
if (contextOptions.config) {
|
|
23
21
|
if (node.path.isAbsolute(contextOptions.config)) {
|
|
24
22
|
configPath = contextOptions.config;
|
|
@@ -28,7 +26,6 @@ function gulpPostcss(cb) {
|
|
|
28
26
|
} else {
|
|
29
27
|
configPath = file.dirname;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
29
|
const ctx = {
|
|
33
30
|
file,
|
|
34
31
|
options: contextOptions
|
|
@@ -38,22 +35,19 @@ function gulpPostcss(cb) {
|
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
export default gulpPostcss(loadConfig => {
|
|
43
39
|
const stream = new Transform({
|
|
44
40
|
objectMode: true
|
|
45
41
|
});
|
|
46
|
-
|
|
47
42
|
stream._transform = function (file, encoding, cb) {
|
|
48
43
|
if (file.isNull()) {
|
|
49
44
|
return cb(null, file);
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
if (file.isStream()) {
|
|
53
47
|
return handleError('Streams are not supported!');
|
|
54
|
-
}
|
|
55
|
-
|
|
48
|
+
}
|
|
56
49
|
|
|
50
|
+
// Protect `from` and `map` if using gulp-sourcemaps
|
|
57
51
|
const isProtected = file.sourceMap ? {
|
|
58
52
|
from: true,
|
|
59
53
|
map: true
|
|
@@ -67,8 +61,8 @@ export default gulpPostcss(loadConfig => {
|
|
|
67
61
|
} : false
|
|
68
62
|
};
|
|
69
63
|
loadConfig(file).then(function (config) {
|
|
70
|
-
const configOpts = config.options || {};
|
|
71
|
-
|
|
64
|
+
const configOpts = config.options || {};
|
|
65
|
+
// Extend the default options if not protected
|
|
72
66
|
for (const opt in configOpts) {
|
|
73
67
|
if (Object.prototype.hasOwnProperty.call(configOpts, opt) && !isProtected[opt]) {
|
|
74
68
|
options[opt] = configOpts[opt];
|
|
@@ -76,15 +70,14 @@ export default gulpPostcss(loadConfig => {
|
|
|
76
70
|
BalmJS.logger.info(PLUGIN_NAME, `${file.relative}\nCannot override ${opt} option, because it is required by gulp-sourcemaps`);
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
|
-
|
|
80
73
|
return postcss(config.plugins || []).process(file.contents, options);
|
|
81
74
|
}).then(handleResult, handleError);
|
|
82
|
-
|
|
83
75
|
function handleResult(result) {
|
|
84
76
|
let map;
|
|
85
77
|
const warnings = result.warnings().join('\n');
|
|
86
|
-
file.contents = Buffer.from(result.css);
|
|
78
|
+
file.contents = Buffer.from(result.css);
|
|
87
79
|
|
|
80
|
+
// Apply source map to the chain
|
|
88
81
|
if (file.sourceMap) {
|
|
89
82
|
map = result.map.toJSON();
|
|
90
83
|
map.file = file.relative;
|
|
@@ -93,22 +86,18 @@ export default gulpPostcss(loadConfig => {
|
|
|
93
86
|
});
|
|
94
87
|
applySourceMap(file, map);
|
|
95
88
|
}
|
|
96
|
-
|
|
97
89
|
if (warnings) {
|
|
98
90
|
BalmJS.logger.info(PLUGIN_NAME, `${file.relative}\nwarnings`);
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
setImmediate(function () {
|
|
102
93
|
cb(null, file);
|
|
103
94
|
});
|
|
104
95
|
}
|
|
105
|
-
|
|
106
96
|
function handleError(error) {
|
|
107
97
|
const errorOptions = {
|
|
108
98
|
fileName: file.path,
|
|
109
99
|
showStack: true
|
|
110
100
|
};
|
|
111
|
-
|
|
112
101
|
if (error.name === 'CssSyntaxError') {
|
|
113
102
|
errorOptions.error = error;
|
|
114
103
|
errorOptions.fileName = error.file || file.path;
|
|
@@ -116,15 +105,13 @@ export default gulpPostcss(loadConfig => {
|
|
|
116
105
|
errorOptions.showProperties = false;
|
|
117
106
|
errorOptions.showStack = false;
|
|
118
107
|
error = `${error.message}\n\n${error.showSourceCode()}\n`;
|
|
119
|
-
}
|
|
108
|
+
}
|
|
109
|
+
// Prevent stream’s unhandled exception from
|
|
120
110
|
// being suppressed by Promise
|
|
121
|
-
|
|
122
|
-
|
|
123
111
|
setImmediate(function () {
|
|
124
112
|
cb(new PluginError('gulp-postcss', error, errorOptions));
|
|
125
113
|
});
|
|
126
114
|
}
|
|
127
115
|
};
|
|
128
|
-
|
|
129
116
|
return stream;
|
|
130
117
|
});
|
package/lib/plugins/rename.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Reference `gulp-rename@2.0.0`
|
|
2
2
|
import { Transform } from 'node:stream';
|
|
3
|
-
|
|
4
3
|
function gulpRename(obj, options = {}) {
|
|
5
4
|
const stream = new Transform({
|
|
6
5
|
objectMode: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
const parsePath = _path => {
|
|
10
8
|
const extname = options.multiExt ? node.path.basename(_path).slice(node.path.basename(_path).indexOf('.')) : node.path.extname(_path);
|
|
11
9
|
return {
|
|
@@ -14,26 +12,20 @@ function gulpRename(obj, options = {}) {
|
|
|
14
12
|
extname: extname
|
|
15
13
|
};
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
stream._transform = (chunk, unused, callback) => {
|
|
19
16
|
const file = chunk.clone({
|
|
20
17
|
contents: false
|
|
21
18
|
});
|
|
22
19
|
let parsedPath = parsePath(file.relative);
|
|
23
|
-
|
|
24
20
|
let _path;
|
|
25
|
-
|
|
26
21
|
const type = typeof obj;
|
|
27
|
-
|
|
28
22
|
if (type === 'string' && obj !== '') {
|
|
29
23
|
_path = obj;
|
|
30
24
|
} else if (type === 'function') {
|
|
31
25
|
const newParsedPath = obj(parsedPath, file);
|
|
32
|
-
|
|
33
26
|
if (typeof newParsedPath === 'object' && newParsedPath !== null) {
|
|
34
27
|
parsedPath = newParsedPath;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
_path = node.path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
|
|
38
30
|
} else if (type === 'object' && obj !== undefined && obj !== null) {
|
|
39
31
|
const _obj = obj;
|
|
@@ -48,17 +40,14 @@ function gulpRename(obj, options = {}) {
|
|
|
48
40
|
callback(new Error('Unsupported renaming parameter type supplied'), undefined);
|
|
49
41
|
return;
|
|
50
42
|
}
|
|
43
|
+
file.path = node.path.join(file.base, _path);
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
// Rename sourcemap if present
|
|
54
46
|
if (file.sourceMap) {
|
|
55
47
|
file.sourceMap.file = file.relative;
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
callback(null, file);
|
|
59
50
|
};
|
|
60
|
-
|
|
61
51
|
return stream;
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
export default gulpRename;
|
package/lib/plugins/replace.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
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; }
|
|
2
|
-
|
|
3
2
|
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) { _defineProperty(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; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
// Reference `gulp-replace@1.1.3`
|
|
8
5
|
import { Transform } from 'node:stream';
|
|
9
6
|
import { isText } from 'istextorbinary';
|
|
@@ -11,13 +8,11 @@ import rs from '../utilities/replacestream.js';
|
|
|
11
8
|
const defaultOptions = {
|
|
12
9
|
skipBinary: true
|
|
13
10
|
};
|
|
14
|
-
|
|
15
11
|
function gulpReplace(search, _replacement, options = {}) {
|
|
16
12
|
// merge options
|
|
17
13
|
options = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
18
14
|
return new Transform({
|
|
19
15
|
objectMode: true,
|
|
20
|
-
|
|
21
16
|
/**
|
|
22
17
|
* transformation
|
|
23
18
|
* @param {import("vinyl")} file
|
|
@@ -28,62 +23,52 @@ function gulpReplace(search, _replacement, options = {}) {
|
|
|
28
23
|
if (file.isNull()) {
|
|
29
24
|
return callback(null, file);
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
let replacement = _replacement;
|
|
33
|
-
|
|
34
27
|
if (typeof _replacement === 'function') {
|
|
35
28
|
// Pass the vinyl file object as this.file
|
|
36
29
|
replacement = _replacement.bind({
|
|
37
30
|
file: file
|
|
38
31
|
});
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
function doReplace() {
|
|
42
34
|
if (file.isStream()) {
|
|
43
35
|
file.contents = file.contents.pipe(rs(search, replacement));
|
|
44
36
|
return callback(null, file);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
if (file.isBuffer()) {
|
|
48
39
|
const content = file.contents.toString();
|
|
49
|
-
|
|
50
40
|
if (search instanceof RegExp) {
|
|
51
41
|
file.contents = Buffer.from(content.replace(search, replacement));
|
|
52
42
|
} else {
|
|
53
43
|
const chunks = content.split(search);
|
|
54
44
|
let result;
|
|
55
|
-
|
|
56
45
|
if (typeof replacement === 'function') {
|
|
57
46
|
// Start with the first chunk already in the result
|
|
58
47
|
// Replacements will be added thereafter
|
|
59
48
|
// This is done to avoid checking the value of i in the loop
|
|
60
|
-
result = [chunks[0]];
|
|
49
|
+
result = [chunks[0]];
|
|
61
50
|
|
|
51
|
+
// The replacement function should be called once for each match
|
|
62
52
|
for (let i = 1; i < chunks.length; i++) {
|
|
63
53
|
// Add the replacement value
|
|
64
|
-
result.push(replacement(search));
|
|
54
|
+
result.push(replacement(search));
|
|
65
55
|
|
|
56
|
+
// Add the next chunk
|
|
66
57
|
result.push(chunks[i]);
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
result = result.join('');
|
|
70
60
|
} else {
|
|
71
61
|
result = chunks.join(replacement);
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
file.contents = Buffer.from(result);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
return callback(null, file);
|
|
78
66
|
}
|
|
79
|
-
|
|
80
67
|
callback(null, file);
|
|
81
68
|
}
|
|
82
|
-
|
|
83
69
|
if (options.skipBinary) {
|
|
84
70
|
// fix@istextorbinary: "editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening."
|
|
85
71
|
const isNode16 = process.version.split('.')[0] === 'v16';
|
|
86
|
-
|
|
87
72
|
if (isNode16) {
|
|
88
73
|
doReplace();
|
|
89
74
|
} else {
|
|
@@ -93,13 +78,10 @@ function gulpReplace(search, _replacement, options = {}) {
|
|
|
93
78
|
callback(null, file);
|
|
94
79
|
}
|
|
95
80
|
}
|
|
96
|
-
|
|
97
81
|
return;
|
|
98
82
|
}
|
|
99
|
-
|
|
100
83
|
doReplace();
|
|
101
84
|
}
|
|
102
85
|
});
|
|
103
86
|
}
|
|
104
|
-
|
|
105
87
|
export default gulpReplace;
|
package/lib/plugins/sass.js
CHANGED
|
@@ -6,56 +6,50 @@ import stripAnsi from 'strip-ansi';
|
|
|
6
6
|
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
7
7
|
import ansiColors from 'ansi-colors';
|
|
8
8
|
const PLUGIN_NAME = 'sass';
|
|
9
|
-
|
|
10
9
|
const transformObj = transform => new Transform({
|
|
11
10
|
transform,
|
|
12
11
|
objectMode: true
|
|
13
12
|
});
|
|
13
|
+
|
|
14
14
|
/**
|
|
15
15
|
* Handles returning the file to the stream
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
17
|
const filePush = (file, sassObject, callback) => {
|
|
20
18
|
// Build Source Maps!
|
|
21
19
|
if (sassObject.map) {
|
|
22
20
|
// Transform map into JSON
|
|
23
|
-
const sassMap = JSON.parse(sassObject.map.toString());
|
|
24
|
-
|
|
25
|
-
const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
26
|
-
|
|
27
|
-
const sassFileSrc = file.relative;
|
|
28
|
-
|
|
21
|
+
const sassMap = JSON.parse(sassObject.map.toString());
|
|
22
|
+
// Grab the stdout and transform it into stdin
|
|
23
|
+
const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
24
|
+
// Grab the base filename that's being worked on
|
|
25
|
+
const sassFileSrc = file.relative;
|
|
26
|
+
// Grab the path portion of the file that's being worked on
|
|
29
27
|
const sassFileSrcPath = node.path.dirname(sassFileSrc);
|
|
30
|
-
|
|
31
28
|
if (sassFileSrcPath) {
|
|
32
|
-
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
33
|
-
|
|
29
|
+
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
30
|
+
// Prepend the path to all files in the sources array except the file that's being worked on
|
|
34
31
|
sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex ? source : node.path.join(sassFileSrcPath, source));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src); // Replace the map file with the original filename (but new extension)
|
|
32
|
+
}
|
|
39
33
|
|
|
40
|
-
|
|
34
|
+
// Remove 'stdin' from sources and replace with filenames!
|
|
35
|
+
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
|
|
41
36
|
|
|
37
|
+
// Replace the map file with the original filename (but new extension)
|
|
38
|
+
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
39
|
+
// Apply the map
|
|
42
40
|
applySourceMap(file, sassMap);
|
|
43
41
|
}
|
|
44
|
-
|
|
45
42
|
file.contents = sassObject.css;
|
|
46
43
|
file.path = replaceExtension(file.path, '.css');
|
|
47
|
-
|
|
48
44
|
if (file.stat) {
|
|
49
45
|
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
callback(null, file);
|
|
53
48
|
};
|
|
49
|
+
|
|
54
50
|
/**
|
|
55
51
|
* Handles error message
|
|
56
52
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
53
|
const handleError = (error, file, callback) => {
|
|
60
54
|
const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
|
|
61
55
|
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
@@ -65,43 +59,41 @@ const handleError = (error, file, callback) => {
|
|
|
65
59
|
error.message = stripAnsi(message);
|
|
66
60
|
error.relativePath = relativePath;
|
|
67
61
|
return callback(new PluginError(PLUGIN_NAME, error));
|
|
68
|
-
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//////////////////////////////
|
|
69
65
|
// Main Gulp Sass function
|
|
70
66
|
//////////////////////////////
|
|
71
|
-
|
|
72
|
-
|
|
73
67
|
const gulpSass = options => transformObj((file, encoding, callback) => {
|
|
74
68
|
if (file.isNull()) {
|
|
75
69
|
callback(null, file);
|
|
76
70
|
return;
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
if (file.isStream()) {
|
|
80
73
|
callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
81
74
|
return;
|
|
82
75
|
}
|
|
83
|
-
|
|
84
76
|
if (node.path.basename(file.path).startsWith('_')) {
|
|
85
77
|
callback();
|
|
86
78
|
return;
|
|
87
79
|
}
|
|
88
|
-
|
|
89
80
|
if (!file.contents.length) {
|
|
90
81
|
file.path = replaceExtension(file.path, '.css');
|
|
91
82
|
callback(null, file);
|
|
92
83
|
return;
|
|
93
84
|
}
|
|
94
|
-
|
|
95
85
|
const opts = options || {};
|
|
96
|
-
opts.data = file.contents.toString();
|
|
86
|
+
opts.data = file.contents.toString();
|
|
97
87
|
|
|
98
|
-
|
|
88
|
+
// We set the file path here so that libsass can correctly resolve import paths
|
|
89
|
+
opts.file = file.path;
|
|
99
90
|
|
|
91
|
+
// Ensure `indentedSyntax` is true if a `.sass` file
|
|
100
92
|
if (node.path.extname(file.path) === '.sass') {
|
|
101
93
|
opts.indentedSyntax = true;
|
|
102
|
-
}
|
|
103
|
-
|
|
94
|
+
}
|
|
104
95
|
|
|
96
|
+
// Ensure file's parent directory in the include path
|
|
105
97
|
if (opts.includePaths) {
|
|
106
98
|
if (typeof opts.includePaths === 'string') {
|
|
107
99
|
opts.includePaths = [opts.includePaths];
|
|
@@ -109,24 +101,23 @@ const gulpSass = options => transformObj((file, encoding, callback) => {
|
|
|
109
101
|
} else {
|
|
110
102
|
opts.includePaths = [];
|
|
111
103
|
}
|
|
104
|
+
opts.includePaths.unshift(node.path.dirname(file.path));
|
|
112
105
|
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
// Generate Source Maps if the source-map plugin is present
|
|
115
107
|
if (file.sourceMap) {
|
|
116
108
|
opts.sourceMap = file.path;
|
|
117
109
|
opts.omitSourceMapUrl = true;
|
|
118
110
|
opts.sourceMapContents = true;
|
|
119
|
-
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//////////////////////////////
|
|
120
114
|
// Sync Sass render
|
|
121
115
|
//////////////////////////////
|
|
122
|
-
|
|
123
|
-
|
|
124
116
|
try {
|
|
125
117
|
gulpSass.compiler && filePush(file, gulpSass.compiler.renderSync(opts), callback);
|
|
126
118
|
} catch (error) {
|
|
127
119
|
handleError(error, file, callback);
|
|
128
120
|
}
|
|
129
121
|
});
|
|
130
|
-
|
|
131
122
|
gulpSass.compiler = sass;
|
|
132
123
|
export default gulpSass;
|