@parcel/transformer-sass 2.8.4-nightly.0 → 2.9.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/SassTransformer.js +11 -49
- package/package.json +4 -4
package/lib/SassTransformer.js
CHANGED
|
@@ -4,72 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _plugin() {
|
|
9
8
|
const data = require("@parcel/plugin");
|
|
10
|
-
|
|
11
9
|
_plugin = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _path() {
|
|
19
15
|
const data = _interopRequireDefault(require("path"));
|
|
20
|
-
|
|
21
16
|
_path = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _os() {
|
|
29
22
|
const data = require("os");
|
|
30
|
-
|
|
31
23
|
_os = function () {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _sourceMap() {
|
|
39
29
|
const data = _interopRequireDefault(require("@parcel/source-map"));
|
|
40
|
-
|
|
41
30
|
_sourceMap = function () {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _sass() {
|
|
49
36
|
const data = _interopRequireDefault(require("sass"));
|
|
50
|
-
|
|
51
37
|
_sass = function () {
|
|
52
38
|
return data;
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
return data;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
function _util() {
|
|
59
43
|
const data = require("util");
|
|
60
|
-
|
|
61
44
|
_util = function () {
|
|
62
45
|
return data;
|
|
63
46
|
};
|
|
64
|
-
|
|
65
47
|
return data;
|
|
66
48
|
}
|
|
67
|
-
|
|
68
49
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
69
|
-
|
|
70
50
|
// E.g: ~library/file.sass
|
|
71
51
|
const NODE_MODULE_ALIAS_RE = /^~[^/\\]/;
|
|
72
|
-
|
|
73
52
|
var _default = new (_plugin().Transformer)({
|
|
74
53
|
async loadConfig({
|
|
75
54
|
config,
|
|
@@ -78,27 +57,26 @@ var _default = new (_plugin().Transformer)({
|
|
|
78
57
|
let configFile = await config.getConfig(['.sassrc', '.sassrc.json', '.sassrc.js', '.sassrc.cjs', '.sassrc.mjs'], {
|
|
79
58
|
packageKey: 'sass'
|
|
80
59
|
});
|
|
81
|
-
let configResult = configFile ? configFile.contents : {};
|
|
60
|
+
let configResult = configFile ? configFile.contents : {};
|
|
82
61
|
|
|
62
|
+
// Resolve relative paths from config file
|
|
83
63
|
if (configFile && configResult.includePaths) {
|
|
84
64
|
configResult.includePaths = configResult.includePaths.map(p => _path().default.resolve(_path().default.dirname(configFile.filePath), p));
|
|
85
65
|
}
|
|
86
|
-
|
|
87
66
|
if (configResult.importer === undefined) {
|
|
88
67
|
configResult.importer = [];
|
|
89
68
|
} else if (!Array.isArray(configResult.importer)) {
|
|
90
69
|
configResult.importer = [configResult.importer];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
configResult.sourceMap = true; // sources are created relative to the directory of outFile
|
|
70
|
+
}
|
|
95
71
|
|
|
72
|
+
// Always emit sourcemap
|
|
73
|
+
configResult.sourceMap = true;
|
|
74
|
+
// sources are created relative to the directory of outFile
|
|
96
75
|
configResult.outFile = _path().default.join(options.projectRoot, 'style.css.map');
|
|
97
76
|
configResult.omitSourceMapUrl = true;
|
|
98
77
|
configResult.sourceMapContents = false;
|
|
99
78
|
return configResult;
|
|
100
79
|
},
|
|
101
|
-
|
|
102
80
|
async transform({
|
|
103
81
|
asset,
|
|
104
82
|
options,
|
|
@@ -108,10 +86,10 @@ var _default = new (_plugin().Transformer)({
|
|
|
108
86
|
let rawConfig = config !== null && config !== void 0 ? config : {};
|
|
109
87
|
let sassRender = (0, _util().promisify)(_sass().default.render.bind(_sass().default));
|
|
110
88
|
let css;
|
|
111
|
-
|
|
112
89
|
try {
|
|
113
90
|
let code = await asset.getCode();
|
|
114
|
-
let result = await sassRender({
|
|
91
|
+
let result = await sassRender({
|
|
92
|
+
...rawConfig,
|
|
115
93
|
file: asset.filePath,
|
|
116
94
|
data: rawConfig.data ? rawConfig.data + _os().EOL + code : code,
|
|
117
95
|
importer: [...rawConfig.importer, resolvePathImporter({
|
|
@@ -123,13 +101,11 @@ var _default = new (_plugin().Transformer)({
|
|
|
123
101
|
indentedSyntax: typeof rawConfig.indentedSyntax === 'boolean' ? rawConfig.indentedSyntax : asset.type === 'sass'
|
|
124
102
|
});
|
|
125
103
|
css = result.css;
|
|
126
|
-
|
|
127
104
|
for (let included of result.stats.includedFiles) {
|
|
128
105
|
if (included !== asset.filePath) {
|
|
129
106
|
asset.invalidateOnFileChange(included);
|
|
130
107
|
}
|
|
131
108
|
}
|
|
132
|
-
|
|
133
109
|
if (result.map != null) {
|
|
134
110
|
let map = new (_sourceMap().default)(options.projectRoot);
|
|
135
111
|
map.addVLQMap(JSON.parse(result.map));
|
|
@@ -144,16 +120,12 @@ var _default = new (_plugin().Transformer)({
|
|
|
144
120
|
};
|
|
145
121
|
throw err;
|
|
146
122
|
}
|
|
147
|
-
|
|
148
123
|
asset.type = 'css';
|
|
149
124
|
asset.setCode(css);
|
|
150
125
|
return [asset];
|
|
151
126
|
}
|
|
152
|
-
|
|
153
127
|
});
|
|
154
|
-
|
|
155
128
|
exports.default = _default;
|
|
156
|
-
|
|
157
129
|
function resolvePathImporter({
|
|
158
130
|
asset,
|
|
159
131
|
resolve,
|
|
@@ -173,31 +145,24 @@ function resolvePathImporter({
|
|
|
173
145
|
See: https://sass-lang.com/documentation/js-api#importer
|
|
174
146
|
See also: https://github.com/sass/dart-sass/blob/006e6aa62f2417b5267ad5cdb5ba050226fab511/lib/src/importer/node/implementation.dart
|
|
175
147
|
*/
|
|
176
|
-
let paths = [_path().default.dirname(prev)];
|
|
177
148
|
|
|
149
|
+
let paths = [_path().default.dirname(prev)];
|
|
178
150
|
if (includePaths) {
|
|
179
151
|
paths.push(...includePaths);
|
|
180
152
|
}
|
|
181
|
-
|
|
182
153
|
asset.invalidateOnEnvChange('SASS_PATH');
|
|
183
|
-
|
|
184
154
|
if (options.env.SASS_PATH) {
|
|
185
155
|
paths.push(...options.env.SASS_PATH.split(process.platform === 'win32' ? ';' : ':').map(p => _path().default.resolve(options.projectRoot, p)));
|
|
186
156
|
}
|
|
187
|
-
|
|
188
157
|
const urls = [url];
|
|
189
|
-
|
|
190
158
|
const urlFileName = _path().default.basename(url);
|
|
191
|
-
|
|
192
159
|
if (urlFileName[0] !== '_') {
|
|
193
160
|
urls.push(_path().default.join(_path().default.dirname(url), `_${urlFileName}`));
|
|
194
161
|
}
|
|
195
|
-
|
|
196
162
|
if (url[0] !== '~') {
|
|
197
163
|
for (let p of paths) {
|
|
198
164
|
for (let u of urls) {
|
|
199
165
|
const filePath = _path().default.resolve(p, u);
|
|
200
|
-
|
|
201
166
|
try {
|
|
202
167
|
const contents = await asset.fs.readFile(filePath, 'utf8');
|
|
203
168
|
return {
|
|
@@ -211,19 +176,17 @@ function resolvePathImporter({
|
|
|
211
176
|
}
|
|
212
177
|
}
|
|
213
178
|
}
|
|
214
|
-
}
|
|
215
|
-
|
|
179
|
+
}
|
|
216
180
|
|
|
181
|
+
// If none of the default sass rules apply, try Parcel's resolver.
|
|
217
182
|
for (let u of urls) {
|
|
218
183
|
if (NODE_MODULE_ALIAS_RE.test(u)) {
|
|
219
184
|
u = u.slice(1);
|
|
220
185
|
}
|
|
221
|
-
|
|
222
186
|
try {
|
|
223
187
|
const filePath = await resolve(prev, u, {
|
|
224
188
|
packageConditions: ['sass', 'style']
|
|
225
189
|
});
|
|
226
|
-
|
|
227
190
|
if (filePath) {
|
|
228
191
|
const contents = await asset.fs.readFile(filePath, 'utf8');
|
|
229
192
|
return {
|
|
@@ -236,7 +199,6 @@ function resolvePathImporter({
|
|
|
236
199
|
}
|
|
237
200
|
}
|
|
238
201
|
}
|
|
239
|
-
|
|
240
202
|
return function (rawUrl, prev, done) {
|
|
241
203
|
const url = rawUrl.replace(/^file:\/\//, '');
|
|
242
204
|
resolvePath(url, prev).then(resolved => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-sass",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"source": "src/SassTransformer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "2.
|
|
20
|
+
"parcel": "^2.9.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/plugin": "2.
|
|
23
|
+
"@parcel/plugin": "2.9.0",
|
|
24
24
|
"@parcel/source-map": "^2.1.1",
|
|
25
25
|
"sass": "^1.38.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
|
|
28
28
|
}
|