@parcel/transformer-sass 2.13.0 → 2.13.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/modern.js +32 -4
- package/package.json +4 -4
- package/src/modern.js +34 -4
package/lib/modern.js
CHANGED
|
@@ -105,7 +105,12 @@ function resolvePathImporter({
|
|
|
105
105
|
See also: https://github.com/sass/dart-sass/blob/006e6aa62f2417b5267ad5cdb5ba050226fab511/lib/src/importer/node/implementation.dart
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
|
-
let containingPath = (0, _url().fileURLToPath)(containingUrl);
|
|
108
|
+
let containingPath = containingUrl ? (0, _url().fileURLToPath)(containingUrl) : asset.filePath;
|
|
109
|
+
if (!containingUrl) {
|
|
110
|
+
// If containingUrl is not provided, then url should be an absolute file:/// URL.
|
|
111
|
+
let filePath = (0, _url().fileURLToPath)(url);
|
|
112
|
+
url = _path().default.relative(_path().default.dirname(containingPath), filePath);
|
|
113
|
+
}
|
|
109
114
|
let paths = [_path().default.dirname(containingPath)];
|
|
110
115
|
if (loadPaths) {
|
|
111
116
|
paths.push(...loadPaths);
|
|
@@ -114,16 +119,39 @@ function resolvePathImporter({
|
|
|
114
119
|
if (options.env.SASS_PATH) {
|
|
115
120
|
paths.push(...options.env.SASS_PATH.split(process.platform === 'win32' ? ';' : ':').map(p => _path().default.resolve(options.projectRoot, p)));
|
|
116
121
|
}
|
|
122
|
+
|
|
123
|
+
// The importer should look for stylesheets by adding the prefix _ to the URL's basename,
|
|
124
|
+
// and by adding the extensions .sass and .scss if the URL doesn't already have one of those extensions.
|
|
117
125
|
const urls = [url];
|
|
118
126
|
const urlFileName = _path().default.basename(url);
|
|
119
127
|
if (urlFileName[0] !== '_') {
|
|
120
|
-
urls.push(_path().default.join(_path().default.dirname(url), `_${urlFileName}`));
|
|
128
|
+
urls.push(_path().default.posix.join(_path().default.dirname(url), `_${urlFileName}`));
|
|
129
|
+
}
|
|
130
|
+
let ext = _path().default.extname(urlFileName);
|
|
131
|
+
if (ext !== '.sass' && ext !== '.scss') {
|
|
132
|
+
for (let url of [...urls]) {
|
|
133
|
+
urls.push(url + '.sass');
|
|
134
|
+
urls.push(url + '.scss');
|
|
135
|
+
}
|
|
121
136
|
}
|
|
137
|
+
|
|
138
|
+
// If none of the possible paths is valid, the importer should perform the same resolution on the URL followed by /index.
|
|
139
|
+
urls.push(_path().default.posix.join(url, 'index.sass'));
|
|
140
|
+
urls.push(_path().default.posix.join(url, 'index.scss'));
|
|
141
|
+
urls.push(_path().default.posix.join(url, '_index.sass'));
|
|
142
|
+
urls.push(_path().default.posix.join(url, '_index.scss'));
|
|
122
143
|
if (url[0] !== '~') {
|
|
123
144
|
for (let p of paths) {
|
|
124
145
|
for (let u of urls) {
|
|
125
|
-
|
|
126
|
-
|
|
146
|
+
var _stat;
|
|
147
|
+
let filePath = _path().default.resolve(p, u);
|
|
148
|
+
let stat;
|
|
149
|
+
try {
|
|
150
|
+
stat = await asset.fs.stat(filePath);
|
|
151
|
+
} catch (err) {
|
|
152
|
+
// ignore.
|
|
153
|
+
}
|
|
154
|
+
if ((_stat = stat) !== null && _stat !== void 0 && _stat.isFile()) {
|
|
127
155
|
return (0, _url().pathToFileURL)(filePath);
|
|
128
156
|
}
|
|
129
157
|
asset.invalidateOnFileCreate({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-sass",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.1",
|
|
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": ">= 16.0.0",
|
|
20
|
-
"parcel": "^2.13.
|
|
20
|
+
"parcel": "^2.13.1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/plugin": "2.13.
|
|
23
|
+
"@parcel/plugin": "2.13.1",
|
|
24
24
|
"@parcel/source-map": "^2.1.1",
|
|
25
25
|
"sass": "^1.38.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4a297f79db3eec74437f4c5133127c98bf303703"
|
|
28
28
|
}
|
package/src/modern.js
CHANGED
|
@@ -95,7 +95,15 @@ function resolvePathImporter({
|
|
|
95
95
|
See also: https://github.com/sass/dart-sass/blob/006e6aa62f2417b5267ad5cdb5ba050226fab511/lib/src/importer/node/implementation.dart
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
|
-
let containingPath =
|
|
98
|
+
let containingPath = containingUrl
|
|
99
|
+
? fileURLToPath(containingUrl)
|
|
100
|
+
: asset.filePath;
|
|
101
|
+
if (!containingUrl) {
|
|
102
|
+
// If containingUrl is not provided, then url should be an absolute file:/// URL.
|
|
103
|
+
let filePath = fileURLToPath(url);
|
|
104
|
+
url = path.relative(path.dirname(containingPath), filePath);
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
let paths = [path.dirname(containingPath)];
|
|
100
108
|
if (loadPaths) {
|
|
101
109
|
paths.push(...loadPaths);
|
|
@@ -110,17 +118,39 @@ function resolvePathImporter({
|
|
|
110
118
|
);
|
|
111
119
|
}
|
|
112
120
|
|
|
121
|
+
// The importer should look for stylesheets by adding the prefix _ to the URL's basename,
|
|
122
|
+
// and by adding the extensions .sass and .scss if the URL doesn't already have one of those extensions.
|
|
113
123
|
const urls = [url];
|
|
114
124
|
const urlFileName = path.basename(url);
|
|
115
125
|
if (urlFileName[0] !== '_') {
|
|
116
|
-
urls.push(path.join(path.dirname(url), `_${urlFileName}`));
|
|
126
|
+
urls.push(path.posix.join(path.dirname(url), `_${urlFileName}`));
|
|
117
127
|
}
|
|
118
128
|
|
|
129
|
+
let ext = path.extname(urlFileName);
|
|
130
|
+
if (ext !== '.sass' && ext !== '.scss') {
|
|
131
|
+
for (let url of [...urls]) {
|
|
132
|
+
urls.push(url + '.sass');
|
|
133
|
+
urls.push(url + '.scss');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// If none of the possible paths is valid, the importer should perform the same resolution on the URL followed by /index.
|
|
138
|
+
urls.push(path.posix.join(url, 'index.sass'));
|
|
139
|
+
urls.push(path.posix.join(url, 'index.scss'));
|
|
140
|
+
urls.push(path.posix.join(url, '_index.sass'));
|
|
141
|
+
urls.push(path.posix.join(url, '_index.scss'));
|
|
142
|
+
|
|
119
143
|
if (url[0] !== '~') {
|
|
120
144
|
for (let p of paths) {
|
|
121
145
|
for (let u of urls) {
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
let filePath = path.resolve(p, u);
|
|
147
|
+
let stat;
|
|
148
|
+
try {
|
|
149
|
+
stat = await asset.fs.stat(filePath);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
// ignore.
|
|
152
|
+
}
|
|
153
|
+
if (stat?.isFile()) {
|
|
124
154
|
return pathToFileURL(filePath);
|
|
125
155
|
}
|
|
126
156
|
|