balm-core 4.21.1 → 4.22.1
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/bundler/webpack/rules/css.js +2 -2
- package/lib/plugins/less.js +30 -26
- package/lib/plugins/postcss.js +1 -1
- package/lib/plugins/sass.js +18 -72
- package/lib/tasks/public/sass.js +2 -2
- package/package.json +7 -7
- package/tslib/bundler/webpack/rules/css.js +2 -2
- package/tslib/plugins/less.js +28 -27
- package/tslib/plugins/postcss.js +1 -1
- package/tslib/plugins/sass.js +24 -61
- package/tslib/tasks/public/sass.js +2 -2
|
@@ -94,8 +94,8 @@ function cssLoader() {
|
|
|
94
94
|
// Prefer `dart-sass`
|
|
95
95
|
implementation: requireModule.resolve('sass'),
|
|
96
96
|
sassOptions: Object.assign({
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
loadPaths: BalmJS.file.stylePaths,
|
|
98
|
+
sourceMap: true,
|
|
99
99
|
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
100
100
|
}, BalmJS.config.styles.sassOptions)
|
|
101
101
|
}),
|
package/lib/plugins/less.js
CHANGED
|
@@ -23,35 +23,39 @@ function inlineSources(sourcemap) {
|
|
|
23
23
|
return sourcemap;
|
|
24
24
|
}, () => sourcemap);
|
|
25
25
|
}
|
|
26
|
-
function renderLess(
|
|
26
|
+
function renderLess(input, options) {
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
|
-
less.render(
|
|
29
|
-
if (
|
|
30
|
-
reject(
|
|
28
|
+
less.render(input, options, (error, output) => {
|
|
29
|
+
if (error) {
|
|
30
|
+
reject(error);
|
|
31
31
|
} else {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
imports
|
|
32
|
+
const {
|
|
33
|
+
css,
|
|
34
|
+
imports
|
|
35
|
+
} = output;
|
|
36
|
+
const result = {
|
|
37
|
+
css,
|
|
38
|
+
imports
|
|
35
39
|
};
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
inlineSources(
|
|
39
|
-
|
|
40
|
-
resolve(
|
|
40
|
+
if (options.sourceMap && output.map) {
|
|
41
|
+
result.sourcemap = JSON.parse(output.map);
|
|
42
|
+
inlineSources(result.sourcemap).then(map => {
|
|
43
|
+
result.sourcemap = map;
|
|
44
|
+
resolve(result);
|
|
41
45
|
});
|
|
42
46
|
} else {
|
|
43
|
-
resolve(
|
|
47
|
+
resolve(result);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
|
-
function gulpLess(
|
|
53
|
+
function gulpLess(customOptions) {
|
|
50
54
|
// Mixes in default options.
|
|
51
|
-
const
|
|
55
|
+
const options = Object.assign({}, {
|
|
52
56
|
compress: false,
|
|
53
57
|
paths: []
|
|
54
|
-
},
|
|
58
|
+
}, customOptions);
|
|
55
59
|
return through2.obj((file, enc, cb) => {
|
|
56
60
|
if (file.isNull()) {
|
|
57
61
|
return cb(null, file);
|
|
@@ -59,22 +63,22 @@ function gulpLess(options) {
|
|
|
59
63
|
if (file.isStream()) {
|
|
60
64
|
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
61
65
|
}
|
|
62
|
-
const
|
|
66
|
+
const input = file.contents.toString();
|
|
63
67
|
|
|
64
68
|
// Injects the path of the current file
|
|
65
|
-
|
|
69
|
+
options.filename = file.path;
|
|
66
70
|
|
|
67
71
|
// Bootstrap source maps
|
|
68
|
-
if (file.sourceMap ||
|
|
69
|
-
|
|
72
|
+
if (file.sourceMap || options.sourcemap) {
|
|
73
|
+
options.sourceMap = true;
|
|
70
74
|
}
|
|
71
|
-
renderLess(
|
|
72
|
-
file.contents = Buffer.from(
|
|
75
|
+
renderLess(input, options).then(output => {
|
|
76
|
+
file.contents = Buffer.from(output.css);
|
|
73
77
|
file.path = replaceExtension(file.path, '.css');
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
applySourceMap(file,
|
|
78
|
+
if (output.sourcemap) {
|
|
79
|
+
output.sourcemap.file = file.relative;
|
|
80
|
+
output.sourcemap.sources = output.sourcemap.sources.map(source => node.path.relative(file.base, source));
|
|
81
|
+
applySourceMap(file, output.sourcemap);
|
|
78
82
|
}
|
|
79
83
|
return file;
|
|
80
84
|
}).then(file => {
|
package/lib/plugins/postcss.js
CHANGED
|
@@ -109,7 +109,7 @@ export default gulpPostcss(loadConfig => {
|
|
|
109
109
|
// Prevent stream’s unhandled exception from
|
|
110
110
|
// being suppressed by Promise
|
|
111
111
|
setImmediate(function () {
|
|
112
|
-
cb(new PluginError(
|
|
112
|
+
cb(new PluginError(PLUGIN_NAME, error, errorOptions));
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
};
|
package/lib/plugins/sass.js
CHANGED
|
@@ -2,16 +2,17 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
// Reference `gulp-sass@5.1.0`
|
|
4
4
|
import { Transform } from 'node:stream';
|
|
5
|
-
import sass from 'sass';
|
|
5
|
+
import * as sass from 'sass';
|
|
6
6
|
import replaceExtension from 'replace-ext';
|
|
7
7
|
import stripAnsi from 'strip-ansi';
|
|
8
8
|
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
9
9
|
import ansiColors from 'ansi-colors';
|
|
10
10
|
process.env.BALM_CWD = process.env.INIT_CWD || process.cwd();
|
|
11
11
|
const localSassModule = path.join(process.env.BALM_ROOT || process.env.BALM_CWD, 'node_modules', 'sass');
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const nodeLocalSassModule = path.join(localSassModule, 'sass.node.js');
|
|
13
|
+
const defaultLocalSassModule = path.join(localSassModule, 'sass.default.js'); // For `npm i -D sass <= 1.62.1`
|
|
14
|
+
const dartLocalSassModule = path.join(localSassModule, 'sass.dart.js'); // For `npm i -D sass <= 1.39.2`
|
|
15
|
+
const sassModule = fs.existsSync(nodeLocalSassModule) ? requireModule(nodeLocalSassModule) : fs.existsSync(defaultLocalSassModule) ? requireModule(defaultLocalSassModule) : fs.existsSync(dartLocalSassModule) ? requireModule(dartLocalSassModule) : sass;
|
|
15
16
|
const PLUGIN_NAME = 'sass';
|
|
16
17
|
const transformObj = transform => new Transform({
|
|
17
18
|
transform,
|
|
@@ -21,32 +22,16 @@ const transformObj = transform => new Transform({
|
|
|
21
22
|
/**
|
|
22
23
|
* Handles returning the file to the stream
|
|
23
24
|
*/
|
|
24
|
-
const filePush = (file,
|
|
25
|
+
const filePush = (file, result, callback) => {
|
|
25
26
|
// Build Source Maps!
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
const sassMap = JSON.parse(sassObject.map.toString());
|
|
29
|
-
// Grab the stdout and transform it into stdin
|
|
30
|
-
const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
|
|
31
|
-
// Grab the base filename that's being worked on
|
|
32
|
-
const sassFileSrc = file.relative;
|
|
33
|
-
// Grab the path portion of the file that's being worked on
|
|
34
|
-
const sassFileSrcPath = node.path.dirname(sassFileSrc);
|
|
35
|
-
if (sassFileSrcPath) {
|
|
36
|
-
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
37
|
-
// Prepend the path to all files in the sources array except the file that's being worked on
|
|
38
|
-
sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex ? source : node.path.join(sassFileSrcPath, source));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Remove 'stdin' from sources and replace with filenames!
|
|
42
|
-
sassMap.sources = sassMap.sources.filter(src => src !== 'stdin' && src);
|
|
43
|
-
|
|
27
|
+
if (result.sourceMap) {
|
|
28
|
+
const sassMap = result.sourceMap;
|
|
44
29
|
// Replace the map file with the original filename (but new extension)
|
|
45
|
-
sassMap.file = replaceExtension(
|
|
30
|
+
sassMap.file = replaceExtension(file.relative, '.css');
|
|
46
31
|
// Apply the map
|
|
47
32
|
applySourceMap(file, sassMap);
|
|
48
33
|
}
|
|
49
|
-
file.contents =
|
|
34
|
+
file.contents = Buffer.from(result.css);
|
|
50
35
|
file.path = replaceExtension(file.path, '.css');
|
|
51
36
|
if (file.stat) {
|
|
52
37
|
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
@@ -58,13 +43,9 @@ const filePush = (file, sassObject, callback) => {
|
|
|
58
43
|
* Handles error message
|
|
59
44
|
*/
|
|
60
45
|
const handleError = (error, file, callback) => {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
|
|
64
|
-
error.messageFormatted = message;
|
|
65
|
-
error.messageOriginal = error.message;
|
|
46
|
+
const relativePath = node.path.relative(process.cwd(), file.path);
|
|
47
|
+
const message = `${ansiColors.underline(relativePath)}\n${error.message}`;
|
|
66
48
|
error.message = stripAnsi(message);
|
|
67
|
-
error.relativePath = relativePath;
|
|
68
49
|
return callback(new PluginError(PLUGIN_NAME, error));
|
|
69
50
|
};
|
|
70
51
|
|
|
@@ -73,58 +54,23 @@ const handleError = (error, file, callback) => {
|
|
|
73
54
|
//////////////////////////////
|
|
74
55
|
const gulpSass = options => transformObj((file, encoding, callback) => {
|
|
75
56
|
if (file.isNull()) {
|
|
76
|
-
callback(null, file);
|
|
77
|
-
return;
|
|
57
|
+
return callback(null, file);
|
|
78
58
|
}
|
|
79
59
|
if (file.isStream()) {
|
|
80
|
-
callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
81
|
-
return;
|
|
60
|
+
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
82
61
|
}
|
|
83
62
|
if (node.path.basename(file.path).startsWith('_')) {
|
|
84
|
-
callback();
|
|
85
|
-
return;
|
|
63
|
+
return callback();
|
|
86
64
|
}
|
|
87
65
|
if (!file.contents.length) {
|
|
88
66
|
file.path = replaceExtension(file.path, '.css');
|
|
89
|
-
callback(null, file);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const opts = options || {};
|
|
93
|
-
opts.data = file.contents.toString();
|
|
94
|
-
|
|
95
|
-
// We set the file path here so that libsass can correctly resolve import paths
|
|
96
|
-
opts.file = file.path;
|
|
97
|
-
|
|
98
|
-
// Ensure `indentedSyntax` is true if a `.sass` file
|
|
99
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
100
|
-
opts.indentedSyntax = true;
|
|
67
|
+
return callback(null, file);
|
|
101
68
|
}
|
|
102
|
-
|
|
103
|
-
// Ensure file's parent directory in the include path
|
|
104
|
-
if (opts.includePaths) {
|
|
105
|
-
if (typeof opts.includePaths === 'string') {
|
|
106
|
-
opts.includePaths = [opts.includePaths];
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
opts.includePaths = [];
|
|
110
|
-
}
|
|
111
|
-
opts.includePaths.unshift(node.path.dirname(file.path));
|
|
112
|
-
|
|
113
|
-
// Generate Source Maps if the source-map plugin is present
|
|
114
|
-
if (file.sourceMap) {
|
|
115
|
-
opts.sourceMap = file.path;
|
|
116
|
-
opts.omitSourceMapUrl = true;
|
|
117
|
-
opts.sourceMapContents = true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
//////////////////////////////
|
|
121
|
-
// Sync Sass render
|
|
122
|
-
//////////////////////////////
|
|
69
|
+
const path = file.path;
|
|
123
70
|
try {
|
|
124
|
-
|
|
71
|
+
filePush(file, sassModule.compile(path, options), callback);
|
|
125
72
|
} catch (error) {
|
|
126
73
|
handleError(error, file, callback);
|
|
127
74
|
}
|
|
128
75
|
});
|
|
129
|
-
gulpSass.compiler = sassModule;
|
|
130
76
|
export default gulpSass;
|
package/lib/tasks/public/sass.js
CHANGED
|
@@ -4,8 +4,8 @@ class SassTask extends BalmJS.BalmStyleTask {
|
|
|
4
4
|
}
|
|
5
5
|
get options() {
|
|
6
6
|
return Object.assign({
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
loadPaths: BalmJS.file.stylePaths,
|
|
8
|
+
sourceMap: true,
|
|
9
9
|
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
10
10
|
}, BalmJS.config.styles.sassOptions, this.customOptions);
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "balm-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.1",
|
|
4
4
|
"description": "BalmJS compiler core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"balm",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.3",
|
|
45
45
|
"ansi-colors": "^4.1.3",
|
|
46
46
|
"async": "^3.2.4",
|
|
47
|
-
"autoprefixer": "^10.4.
|
|
47
|
+
"autoprefixer": "^10.4.15",
|
|
48
48
|
"babel-loader": "^9.1.3",
|
|
49
49
|
"browser-sync": "^2.29.3",
|
|
50
50
|
"connect-history-api-fallback": "^2.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"del": "^7.0.0",
|
|
55
55
|
"dotenv": "^16.3.1",
|
|
56
56
|
"dotenv-expand": "^10.0.0",
|
|
57
|
-
"esbuild": "^0.
|
|
57
|
+
"esbuild": "^0.19.0",
|
|
58
58
|
"fancy-log": "^2.0.0",
|
|
59
59
|
"gulp-eslint": "^6.0.0",
|
|
60
60
|
"gulp-if": "^3.0.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"http-proxy-middleware": "^2.0.6",
|
|
72
72
|
"imagemin": "^8.0.1",
|
|
73
73
|
"istextorbinary": "^6.0.0",
|
|
74
|
-
"less": "^4.
|
|
74
|
+
"less": "^4.2.0",
|
|
75
75
|
"mini-css-extract-plugin": "^2.7.6",
|
|
76
76
|
"modernizr": "^3.12.0",
|
|
77
77
|
"parents": "^1.0.1",
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"postcss-import": "^15.1.0",
|
|
82
82
|
"postcss-load-config": "^4.0.1",
|
|
83
83
|
"postcss-loader": "7.3.3",
|
|
84
|
-
"postcss-preset-env": "^9.1.
|
|
84
|
+
"postcss-preset-env": "^9.1.1",
|
|
85
85
|
"pretty-bytes": "^6.1.1",
|
|
86
86
|
"readable-stream": "^4.4.2",
|
|
87
87
|
"replace-ext": "^2.0.0",
|
|
88
88
|
"rollup": "^3.24.0",
|
|
89
|
-
"sass": "1.
|
|
89
|
+
"sass": "^1.65.1",
|
|
90
90
|
"sass-loader": "^13.3.2",
|
|
91
91
|
"ssh2": "^1.14.0",
|
|
92
92
|
"strip-ansi": "^7.1.0",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"engines": {
|
|
122
122
|
"node": ">=16"
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "ab3af9d04a485cf0ffa666c9bde1ea3930efbfae"
|
|
125
125
|
}
|
|
@@ -83,8 +83,8 @@ function cssLoader() {
|
|
|
83
83
|
}, 'sass-loader', {
|
|
84
84
|
implementation: requireModule.resolve('sass'),
|
|
85
85
|
sassOptions: Object.assign({
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
loadPaths: BalmJS.file.stylePaths,
|
|
87
|
+
sourceMap: true,
|
|
88
88
|
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
89
89
|
}, BalmJS.config.styles.sassOptions)
|
|
90
90
|
}),
|
package/tslib/plugins/less.js
CHANGED
|
@@ -22,36 +22,37 @@ function inlineSources(sourcemap) {
|
|
|
22
22
|
return sourcemap;
|
|
23
23
|
}, () => sourcemap);
|
|
24
24
|
}
|
|
25
|
-
function renderLess(
|
|
25
|
+
function renderLess(input, options) {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
|
-
less.render(
|
|
28
|
-
if (
|
|
29
|
-
reject(
|
|
27
|
+
less.render(input, options, (error, output) => {
|
|
28
|
+
if (error) {
|
|
29
|
+
reject(error);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const { css, imports } = output;
|
|
33
|
+
const result = {
|
|
34
|
+
css,
|
|
35
|
+
imports
|
|
35
36
|
};
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
inlineSources(
|
|
39
|
-
|
|
40
|
-
resolve(
|
|
37
|
+
if (options.sourceMap && output.map) {
|
|
38
|
+
result.sourcemap = JSON.parse(output.map);
|
|
39
|
+
inlineSources(result.sourcemap).then((map) => {
|
|
40
|
+
result.sourcemap = map;
|
|
41
|
+
resolve(result);
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
|
-
resolve(
|
|
45
|
+
resolve(result);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
function gulpLess(
|
|
51
|
-
const
|
|
51
|
+
function gulpLess(customOptions) {
|
|
52
|
+
const options = Object.assign({}, {
|
|
52
53
|
compress: false,
|
|
53
54
|
paths: []
|
|
54
|
-
},
|
|
55
|
+
}, customOptions);
|
|
55
56
|
return through2.obj((file, enc, cb) => {
|
|
56
57
|
if (file.isNull()) {
|
|
57
58
|
return cb(null, file);
|
|
@@ -59,19 +60,19 @@ function gulpLess(options) {
|
|
|
59
60
|
if (file.isStream()) {
|
|
60
61
|
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
if (file.sourceMap ||
|
|
65
|
-
|
|
63
|
+
const input = file.contents.toString();
|
|
64
|
+
options.filename = file.path;
|
|
65
|
+
if (file.sourceMap || options.sourcemap) {
|
|
66
|
+
options.sourceMap = true;
|
|
66
67
|
}
|
|
67
|
-
renderLess(
|
|
68
|
-
.then((
|
|
69
|
-
file.contents = Buffer.from(
|
|
68
|
+
renderLess(input, options)
|
|
69
|
+
.then((output) => {
|
|
70
|
+
file.contents = Buffer.from(output.css);
|
|
70
71
|
file.path = replaceExtension(file.path, '.css');
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
applySourceMap(file,
|
|
72
|
+
if (output.sourcemap) {
|
|
73
|
+
output.sourcemap.file = file.relative;
|
|
74
|
+
output.sourcemap.sources = output.sourcemap.sources.map((source) => node.path.relative(file.base, source));
|
|
75
|
+
applySourceMap(file, output.sourcemap);
|
|
75
76
|
}
|
|
76
77
|
return file;
|
|
77
78
|
})
|
package/tslib/plugins/postcss.js
CHANGED
|
@@ -103,7 +103,7 @@ export default gulpPostcss((loadConfig) => {
|
|
|
103
103
|
error = `${error.message}\n\n${error.showSourceCode()}\n`;
|
|
104
104
|
}
|
|
105
105
|
setImmediate(function () {
|
|
106
|
-
cb(new PluginError(
|
|
106
|
+
cb(new PluginError(PLUGIN_NAME, error, errorOptions));
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
};
|
package/tslib/plugins/sass.js
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { Transform } from 'node:stream';
|
|
4
|
-
import sass from 'sass';
|
|
4
|
+
import * as sass from 'sass';
|
|
5
5
|
import replaceExtension from 'replace-ext';
|
|
6
6
|
import stripAnsi from 'strip-ansi';
|
|
7
7
|
import applySourceMap from 'vinyl-sourcemaps-apply';
|
|
8
8
|
import ansiColors from 'ansi-colors';
|
|
9
9
|
process.env.BALM_CWD = process.env.INIT_CWD || process.cwd();
|
|
10
10
|
const localSassModule = path.join(process.env.BALM_ROOT || process.env.BALM_CWD, 'node_modules', 'sass');
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const nodeLocalSassModule = path.join(localSassModule, 'sass.node.js');
|
|
12
|
+
const defaultLocalSassModule = path.join(localSassModule, 'sass.default.js');
|
|
13
|
+
const dartLocalSassModule = path.join(localSassModule, 'sass.dart.js');
|
|
14
|
+
const sassModule = fs.existsSync(nodeLocalSassModule)
|
|
15
|
+
? requireModule(nodeLocalSassModule)
|
|
16
|
+
: fs.existsSync(defaultLocalSassModule)
|
|
17
|
+
? requireModule(defaultLocalSassModule)
|
|
18
|
+
: fs.existsSync(dartLocalSassModule)
|
|
19
|
+
? requireModule(dartLocalSassModule)
|
|
20
|
+
: sass;
|
|
18
21
|
const PLUGIN_NAME = 'sass';
|
|
19
22
|
const transformObj = (transform) => new Transform({ transform, objectMode: true });
|
|
20
|
-
const filePush = (file,
|
|
21
|
-
if (
|
|
22
|
-
const sassMap =
|
|
23
|
-
|
|
24
|
-
const sassFileSrc = file.relative;
|
|
25
|
-
const sassFileSrcPath = node.path.dirname(sassFileSrc);
|
|
26
|
-
if (sassFileSrcPath) {
|
|
27
|
-
const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
|
|
28
|
-
sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex
|
|
29
|
-
? source
|
|
30
|
-
: node.path.join(sassFileSrcPath, source));
|
|
31
|
-
}
|
|
32
|
-
sassMap.sources = sassMap.sources.filter((src) => src !== 'stdin' && src);
|
|
33
|
-
sassMap.file = replaceExtension(sassFileSrc, '.css');
|
|
23
|
+
const filePush = (file, result, callback) => {
|
|
24
|
+
if (result.sourceMap) {
|
|
25
|
+
const sassMap = result.sourceMap;
|
|
26
|
+
sassMap.file = replaceExtension(file.relative, '.css');
|
|
34
27
|
applySourceMap(file, sassMap);
|
|
35
28
|
}
|
|
36
|
-
file.contents =
|
|
29
|
+
file.contents = Buffer.from(result.css);
|
|
37
30
|
file.path = replaceExtension(file.path, '.css');
|
|
38
31
|
if (file.stat) {
|
|
39
32
|
file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
|
|
@@ -41,61 +34,31 @@ const filePush = (file, sassObject, callback) => {
|
|
|
41
34
|
callback(null, file);
|
|
42
35
|
};
|
|
43
36
|
const handleError = (error, file, callback) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const relativePath = node.path.relative(process.cwd(), filePath);
|
|
47
|
-
const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
|
|
48
|
-
error.messageFormatted = message;
|
|
49
|
-
error.messageOriginal = error.message;
|
|
37
|
+
const relativePath = node.path.relative(process.cwd(), file.path);
|
|
38
|
+
const message = `${ansiColors.underline(relativePath)}\n${error.message}`;
|
|
50
39
|
error.message = stripAnsi(message);
|
|
51
|
-
error.relativePath = relativePath;
|
|
52
40
|
return callback(new PluginError(PLUGIN_NAME, error));
|
|
53
41
|
};
|
|
54
42
|
const gulpSass = (options) => transformObj((file, encoding, callback) => {
|
|
55
43
|
if (file.isNull()) {
|
|
56
|
-
callback(null, file);
|
|
57
|
-
return;
|
|
44
|
+
return callback(null, file);
|
|
58
45
|
}
|
|
59
46
|
if (file.isStream()) {
|
|
60
|
-
callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
61
|
-
return;
|
|
47
|
+
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
62
48
|
}
|
|
63
49
|
if (node.path.basename(file.path).startsWith('_')) {
|
|
64
|
-
callback();
|
|
65
|
-
return;
|
|
50
|
+
return callback();
|
|
66
51
|
}
|
|
67
52
|
if (!file.contents.length) {
|
|
68
53
|
file.path = replaceExtension(file.path, '.css');
|
|
69
|
-
callback(null, file);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const opts = (options || {});
|
|
73
|
-
opts.data = file.contents.toString();
|
|
74
|
-
opts.file = file.path;
|
|
75
|
-
if (node.path.extname(file.path) === '.sass') {
|
|
76
|
-
opts.indentedSyntax = true;
|
|
77
|
-
}
|
|
78
|
-
if (opts.includePaths) {
|
|
79
|
-
if (typeof opts.includePaths === 'string') {
|
|
80
|
-
opts.includePaths = [opts.includePaths];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
opts.includePaths = [];
|
|
85
|
-
}
|
|
86
|
-
opts.includePaths.unshift(node.path.dirname(file.path));
|
|
87
|
-
if (file.sourceMap) {
|
|
88
|
-
opts.sourceMap = file.path;
|
|
89
|
-
opts.omitSourceMapUrl = true;
|
|
90
|
-
opts.sourceMapContents = true;
|
|
54
|
+
return callback(null, file);
|
|
91
55
|
}
|
|
56
|
+
const path = file.path;
|
|
92
57
|
try {
|
|
93
|
-
|
|
94
|
-
filePush(file, gulpSass.compiler.renderSync(opts), callback);
|
|
58
|
+
filePush(file, sassModule.compile(path, options), callback);
|
|
95
59
|
}
|
|
96
60
|
catch (error) {
|
|
97
61
|
handleError(error, file, callback);
|
|
98
62
|
}
|
|
99
63
|
});
|
|
100
|
-
gulpSass.compiler = sassModule;
|
|
101
64
|
export default gulpSass;
|
|
@@ -4,8 +4,8 @@ class SassTask extends BalmJS.BalmStyleTask {
|
|
|
4
4
|
}
|
|
5
5
|
get options() {
|
|
6
6
|
return Object.assign({
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
loadPaths: BalmJS.file.stylePaths,
|
|
8
|
+
sourceMap: true,
|
|
9
9
|
quietDeps: BalmJS.config.logs.level < BalmJS.LogLevel.Warn
|
|
10
10
|
}, BalmJS.config.styles.sassOptions, this.customOptions);
|
|
11
11
|
}
|