sass-loader 12.2.0 → 12.3.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/README.md +67 -7
- package/dist/SassError.js +2 -1
- package/dist/SassWarning.js +25 -0
- package/dist/options.json +5 -0
- package/dist/utils.js +52 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -119,13 +119,14 @@ Thankfully there are a two solutions to this problem:
|
|
|
119
119
|
|
|
120
120
|
## Options
|
|
121
121
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
122
|
+
| Name | Type | Default | Description |
|
|
123
|
+
| :-------------------------------------------: | :------------------: | :-------------------------------------: | :---------------------------------------------------------------- |
|
|
124
|
+
| **[`implementation`](#implementation)** | `{Object\|String}` | `sass` | Setup Sass implementation to use. |
|
|
125
|
+
| **[`sassOptions`](#sassoptions)** | `{Object\|Function}` | defaults values for Sass implementation | Options for Sass. |
|
|
126
|
+
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
|
|
127
|
+
| **[`additionalData`](#additionaldata)** | `{String\|Function}` | `undefined` | Prepends/Appends `Sass`/`SCSS` code before the actual entry file. |
|
|
128
|
+
| **[`webpackImporter`](#webpackimporter)** | `{Boolean}` | `true` | Enables/Disables the default Webpack importer. |
|
|
129
|
+
| **[`warnRuleAsWarning`](#warnruleaswarning)** | `{Boolean}` | `false` | Treats the `@warn` rule as a webpack warning. |
|
|
129
130
|
|
|
130
131
|
### `implementation`
|
|
131
132
|
|
|
@@ -604,6 +605,65 @@ module.exports = {
|
|
|
604
605
|
};
|
|
605
606
|
```
|
|
606
607
|
|
|
608
|
+
### `warnRuleAsWarning`
|
|
609
|
+
|
|
610
|
+
Type: `Boolean`
|
|
611
|
+
Default: `false`
|
|
612
|
+
|
|
613
|
+
Treats the `@warn` rule as a webpack warning.
|
|
614
|
+
|
|
615
|
+
> ℹ️ It will be `true` by default in the next major release.
|
|
616
|
+
|
|
617
|
+
**style.scss**
|
|
618
|
+
|
|
619
|
+
```scss
|
|
620
|
+
$known-prefixes: webkit, moz, ms, o;
|
|
621
|
+
|
|
622
|
+
@mixin prefix($property, $value, $prefixes) {
|
|
623
|
+
@each $prefix in $prefixes {
|
|
624
|
+
@if not index($known-prefixes, $prefix) {
|
|
625
|
+
@warn "Unknown prefix #{$prefix}.";
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
-#{$prefix}-#{$property}: $value;
|
|
629
|
+
}
|
|
630
|
+
#{$property}: $value;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.tilt {
|
|
634
|
+
// Oops, we typo'd "webkit" as "wekbit"!
|
|
635
|
+
@include prefix(transform, rotate(15deg), wekbit ms);
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
The presented code will throw webpack warning instead logging.
|
|
640
|
+
|
|
641
|
+
To ignore unnecessary warnings you can use the [ignoreWarnings](https://webpack.js.org/configuration/other-options/#ignorewarnings) option.
|
|
642
|
+
|
|
643
|
+
**webpack.config.js**
|
|
644
|
+
|
|
645
|
+
```js
|
|
646
|
+
module.exports = {
|
|
647
|
+
module: {
|
|
648
|
+
rules: [
|
|
649
|
+
{
|
|
650
|
+
test: /\.s[ac]ss$/i,
|
|
651
|
+
use: [
|
|
652
|
+
"style-loader",
|
|
653
|
+
"css-loader",
|
|
654
|
+
{
|
|
655
|
+
loader: "sass-loader",
|
|
656
|
+
options: {
|
|
657
|
+
warnRuleAsWarning: true,
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
},
|
|
662
|
+
],
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
```
|
|
666
|
+
|
|
607
667
|
## Examples
|
|
608
668
|
|
|
609
669
|
### Extracts CSS into separate files
|
package/dist/SassError.js
CHANGED
|
@@ -8,7 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
class SassError extends Error {
|
|
9
9
|
constructor(sassError) {
|
|
10
10
|
super();
|
|
11
|
-
this.name = "SassError";
|
|
11
|
+
this.name = "SassError"; // TODO remove me in the next major release
|
|
12
|
+
|
|
12
13
|
this.originalSassError = sassError;
|
|
13
14
|
this.loc = {
|
|
14
15
|
line: sassError.line,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
class SassWarning extends Error {
|
|
9
|
+
constructor(warning, options) {
|
|
10
|
+
super(warning);
|
|
11
|
+
this.name = "SassWarning";
|
|
12
|
+
this.hideStack = true;
|
|
13
|
+
|
|
14
|
+
if (options.span) {
|
|
15
|
+
this.loc = {
|
|
16
|
+
line: options.span.start.line,
|
|
17
|
+
column: options.span.start.column
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var _default = SassWarning;
|
|
25
|
+
exports.default = _default;
|
package/dist/options.json
CHANGED
|
@@ -48,6 +48,11 @@
|
|
|
48
48
|
"description": "Enables/Disables default `webpack` importer.",
|
|
49
49
|
"link": "https://github.com/webpack-contrib/sass-loader#webpackimporter",
|
|
50
50
|
"type": "boolean"
|
|
51
|
+
},
|
|
52
|
+
"warnRuleAsWarning": {
|
|
53
|
+
"description": "Treats the '@warn' rule as a webpack warning.",
|
|
54
|
+
"link": "https://github.com/webpack-contrib/sass-loader#warnruleaswarning",
|
|
55
|
+
"type": "boolean"
|
|
51
56
|
}
|
|
52
57
|
},
|
|
53
58
|
"additionalProperties": false
|
package/dist/utils.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getRenderFunctionFromSassImplementation = getRenderFunctionFromSassImplementation;
|
|
6
7
|
exports.getSassImplementation = getSassImplementation;
|
|
7
8
|
exports.getSassOptions = getSassOptions;
|
|
8
|
-
exports.getWebpackResolver = getWebpackResolver;
|
|
9
9
|
exports.getWebpackImporter = getWebpackImporter;
|
|
10
|
-
exports.
|
|
11
|
-
exports.normalizeSourceMap = normalizeSourceMap;
|
|
10
|
+
exports.getWebpackResolver = getWebpackResolver;
|
|
12
11
|
exports.isSupportedFibers = isSupportedFibers;
|
|
12
|
+
exports.normalizeSourceMap = normalizeSourceMap;
|
|
13
13
|
|
|
14
14
|
var _url = _interopRequireDefault(require("url"));
|
|
15
15
|
|
|
@@ -19,6 +19,8 @@ var _full = require("klona/full");
|
|
|
19
19
|
|
|
20
20
|
var _neoAsync = _interopRequireDefault(require("neo-async"));
|
|
21
21
|
|
|
22
|
+
var _SassWarning = _interopRequireDefault(require("./SassWarning"));
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
26
|
function getDefaultSassImplementation() {
|
|
@@ -161,7 +163,7 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
161
163
|
options.file = loaderContext.resourcePath;
|
|
162
164
|
options.data = loaderOptions.additionalData ? typeof loaderOptions.additionalData === "function" ? await loaderOptions.additionalData(content, loaderContext) : `${loaderOptions.additionalData}\n${content}` : content; // opt.outputStyle
|
|
163
165
|
|
|
164
|
-
if (
|
|
166
|
+
if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
|
|
165
167
|
options.outputStyle = "compressed";
|
|
166
168
|
}
|
|
167
169
|
|
|
@@ -201,6 +203,52 @@ async function getSassOptions(loaderContext, loaderOptions, content, implementat
|
|
|
201
203
|
options.charset = true;
|
|
202
204
|
}
|
|
203
205
|
|
|
206
|
+
if (!options.logger) {
|
|
207
|
+
// TODO set me to `true` by default in the next major release
|
|
208
|
+
const needEmitWarning = loaderOptions.warnRuleAsWarning === true;
|
|
209
|
+
const logger = loaderContext.getLogger("sass-loader");
|
|
210
|
+
|
|
211
|
+
const formatSpan = span => `${span.url || "-"}:${span.start.line}:${span.start.column}: `;
|
|
212
|
+
|
|
213
|
+
options.logger = {
|
|
214
|
+
debug(message, loggerOptions) {
|
|
215
|
+
let builtMessage = "";
|
|
216
|
+
|
|
217
|
+
if (loggerOptions.span) {
|
|
218
|
+
builtMessage = formatSpan(loggerOptions.span);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
builtMessage += message;
|
|
222
|
+
logger.debug(builtMessage);
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
warn(message, loggerOptions) {
|
|
226
|
+
let builtMessage = "";
|
|
227
|
+
|
|
228
|
+
if (loggerOptions.deprecation) {
|
|
229
|
+
builtMessage += "Deprecation ";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (loggerOptions.span && !loggerOptions.stack) {
|
|
233
|
+
builtMessage = formatSpan(loggerOptions.span);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
builtMessage += message;
|
|
237
|
+
|
|
238
|
+
if (loggerOptions.stack) {
|
|
239
|
+
builtMessage += `\n\n${loggerOptions.stack}`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (needEmitWarning) {
|
|
243
|
+
loaderContext.emitWarning(new _SassWarning.default(builtMessage, loggerOptions));
|
|
244
|
+
} else {
|
|
245
|
+
logger.warn(builtMessage);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
204
252
|
return options;
|
|
205
253
|
}
|
|
206
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.0",
|
|
4
4
|
"description": "Sass loader for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/sass-loader",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"del": "^6.0.0",
|
|
75
75
|
"del-cli": "^4.0.1",
|
|
76
76
|
"enhanced-resolve": "^5.8.2",
|
|
77
|
-
"eslint": "^
|
|
77
|
+
"eslint": "^8.1.0",
|
|
78
78
|
"eslint-config-prettier": "^8.3.0",
|
|
79
79
|
"eslint-plugin-import": "^2.23.3",
|
|
80
80
|
"fibers": "^5.0.0",
|