sass-loader 7.0.3 → 7.3.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/CHANGELOG.md +52 -1
- package/LICENSE +16 -14
- package/README.md +400 -152
- package/dist/cjs.js +5 -0
- package/dist/formatSassError.js +82 -0
- package/dist/getSassOptions.js +106 -0
- package/dist/importsToResolve.js +88 -0
- package/dist/index.js +202 -0
- package/dist/options.json +9 -0
- package/{lib → dist}/proxyCustomImporters.js +14 -12
- package/dist/webpackImporter.js +75 -0
- package/package.json +71 -47
- package/lib/formatSassError.js +0 -73
- package/lib/importsToResolve.js +0 -60
- package/lib/loader.js +0 -95
- package/lib/normalizeOptions.js +0 -78
- package/lib/webpackImporter.js +0 -72
package/README.md
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
[![npm][npm]][npm-url]
|
|
2
|
-
[![node][node]][node-url]
|
|
3
|
-
[![npm-stats][npm-stats]][npm-url]
|
|
4
|
-
[![deps][deps]][deps-url]
|
|
5
|
-
[![travis][travis]][travis-url]
|
|
6
|
-
[![appveyor][appveyor]][appveyor-url]
|
|
7
|
-
[![coverage][cover]][cover-url]
|
|
8
|
-
[![chat][chat]][chat-url]
|
|
9
|
-
|
|
10
1
|
<div align="center">
|
|
11
2
|
<img height="100"
|
|
12
3
|
src="https://worldvectorlogo.com/logos/sass-1.svg">
|
|
@@ -14,223 +5,480 @@
|
|
|
14
5
|
<img width="200" height="200"
|
|
15
6
|
src="https://webpack.js.org/assets/icon-square-big.svg">
|
|
16
7
|
</a>
|
|
17
|
-
<h1>Sass Loader</h1>
|
|
18
|
-
<p>Loads a Sass/SCSS file and compiles it to CSS.</p>
|
|
19
8
|
</div>
|
|
20
9
|
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
[![npm][npm]][npm-url]
|
|
11
|
+
[![node][node]][node-url]
|
|
12
|
+
[![deps][deps]][deps-url]
|
|
13
|
+
[![tests][tests]][tests-url]
|
|
14
|
+
[![coverage][cover]][cover-url]
|
|
15
|
+
[![chat][chat]][chat-url]
|
|
16
|
+
[![size][size]][size-url]
|
|
17
|
+
|
|
18
|
+
# sass-loader
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
Loads a Sass/SCSS file and compiles it to CSS.
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
## Getting Started
|
|
23
|
+
|
|
24
|
+
To begin, you'll need to install `sass-loader`:
|
|
25
|
+
|
|
26
|
+
```console
|
|
27
27
|
npm install sass-loader node-sass webpack --save-dev
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
The sass-loader requires [
|
|
31
|
-
|
|
30
|
+
The sass-loader requires you to install either [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](https://github.com/sass/dart-sass) on your own (more documentation you can find below).
|
|
31
|
+
This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
|
|
32
|
+
|
|
33
|
+
- [node sass](https://github.com/sass/node-sass)
|
|
34
|
+
- [dart sass](http://sass-lang.com/dart-sass)
|
|
35
|
+
|
|
36
|
+
Chain the sass-loader with the [css-loader](https://github.com/webpack-contrib/css-loader) and the [style-loader](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM or the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
Then add the loader to your `webpack` config. For example:
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
**file.js**
|
|
36
41
|
|
|
37
|
-
```
|
|
38
|
-
|
|
42
|
+
```js
|
|
43
|
+
import style from './style.scss';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**file.scss**
|
|
47
|
+
|
|
48
|
+
```scss
|
|
49
|
+
$body-color: red;
|
|
50
|
+
|
|
51
|
+
body {
|
|
52
|
+
color: $body-color;
|
|
53
|
+
}
|
|
39
54
|
```
|
|
40
55
|
|
|
56
|
+
**webpack.config.js**
|
|
57
|
+
|
|
41
58
|
```js
|
|
42
|
-
// webpack.config.js
|
|
43
59
|
module.exports = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
module: {
|
|
61
|
+
rules: [
|
|
62
|
+
{
|
|
63
|
+
test: /\.s[ac]ss$/i,
|
|
64
|
+
use: [
|
|
65
|
+
// Creates `style` nodes from JS strings
|
|
66
|
+
'style-loader',
|
|
67
|
+
// Translates CSS into CommonJS
|
|
68
|
+
'css-loader',
|
|
69
|
+
// Compiles Sass to CSS
|
|
70
|
+
'sass-loader',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
55
75
|
};
|
|
56
76
|
```
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
And run `webpack` via your preferred method.
|
|
79
|
+
|
|
80
|
+
### Resolving `import` at-rules
|
|
81
|
+
|
|
82
|
+
The webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).
|
|
83
|
+
|
|
84
|
+
The sass-loader uses Sass's custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your Sass modules from `node_modules`. Just prepend them with a `~` to tell webpack that this is not a relative import:
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
@import '~bootstrap';
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
It's important to only prepend it with `~`, because `~/` resolves to the home directory.
|
|
91
|
+
The webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files.
|
|
92
|
+
Writing `@import "file"` is the same as `@import "./file";`
|
|
93
|
+
|
|
94
|
+
### Problems with `url(...)`
|
|
95
|
+
|
|
96
|
+
Since sass implementations don't provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.
|
|
97
|
+
|
|
98
|
+
- If you pass the generated CSS on to the css-loader, all urls must be relative to the entry-file (e.g. `main.scss`).
|
|
99
|
+
- If you're just generating CSS without passing it to the css-loader, it must be relative to your web root.
|
|
100
|
+
|
|
101
|
+
You will be disrupted by this first issue. It is natural to expect relative references to be resolved against the `.sass`/`.scss` file in which they are specified (like in regular `.css` files).
|
|
102
|
+
|
|
103
|
+
Thankfully there are a two solutions to this problem:
|
|
104
|
+
|
|
105
|
+
- Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before the sass-loader in the loader chain.
|
|
106
|
+
- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`.
|
|
107
|
+
|
|
108
|
+
## Options
|
|
109
|
+
|
|
110
|
+
By default all options passed to loader also passed to to [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass)
|
|
111
|
+
|
|
112
|
+
> ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
|
|
113
|
+
> ℹ️ Options such as `file` and `outFile` are unavailable.
|
|
114
|
+
> ℹ️ Only the "expanded" and "compressed" values of outputStyle are supported for `dart-sass`.
|
|
115
|
+
> ℹ We recommend don't use `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because loader automatically setup this options.
|
|
116
|
+
|
|
117
|
+
There is a slight difference between the `node-sass` and `sass` options. We recommend look documentation before used them:
|
|
118
|
+
|
|
119
|
+
- [the Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options.
|
|
120
|
+
- [the Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api) for all available `sass` options.
|
|
121
|
+
|
|
122
|
+
**webpack.config.js**
|
|
59
123
|
|
|
60
124
|
```js
|
|
61
|
-
// webpack.config.js
|
|
62
125
|
module.exports = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
126
|
+
module: {
|
|
127
|
+
rules: [
|
|
128
|
+
{
|
|
129
|
+
test: /\.s[ac]ss$/i,
|
|
130
|
+
use: [
|
|
131
|
+
'style-loader',
|
|
132
|
+
'css-loader',
|
|
133
|
+
{
|
|
134
|
+
loader: 'sass-loader',
|
|
135
|
+
options: {
|
|
136
|
+
indentWidth: 4,
|
|
137
|
+
includePaths: ['absolute/path/a', 'absolute/path/b'],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### `implementation`
|
|
148
|
+
|
|
149
|
+
The special `implementation` option determines which implementation of Sass to use.
|
|
150
|
+
|
|
151
|
+
By default the loader resolve the implementation based on your dependencies.
|
|
152
|
+
Just add required implementation to `package.json` (`node-sass` or `sass` package) and install dependencies.
|
|
153
|
+
|
|
154
|
+
Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
|
|
155
|
+
|
|
156
|
+
**package.json**
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"devDependencies": {
|
|
161
|
+
"sass-loader": "^7.2.0",
|
|
162
|
+
"sass": "^1.22.10"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Example where the `sass-loader` loader uses the `node-sass` implementation:
|
|
168
|
+
|
|
169
|
+
**package.json**
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"devDependencies": {
|
|
174
|
+
"sass-loader": "^7.2.0",
|
|
175
|
+
"node-sass": "^4.0.0"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Beware the situation when `node-sass` and `sass` was installed, by default the `sass-loader` prefers `node-sass`, to avoid this situation use the `implementation` option.
|
|
181
|
+
|
|
182
|
+
It takes either `node-sass` or `sass` (`Dart Sass`) module.
|
|
183
|
+
|
|
184
|
+
For example, to use Dart Sass, you'd pass:
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
module.exports = {
|
|
188
|
+
module: {
|
|
189
|
+
rules: [
|
|
190
|
+
{
|
|
191
|
+
test: /\.s[ac]ss$/i,
|
|
192
|
+
use: [
|
|
193
|
+
'style-loader',
|
|
194
|
+
'css-loader',
|
|
195
|
+
{
|
|
196
|
+
loader: 'sass-loader',
|
|
197
|
+
options: {
|
|
198
|
+
// Prefer `dart-sass`
|
|
199
|
+
implementation: require('sass'),
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
},
|
|
79
206
|
};
|
|
80
207
|
```
|
|
81
208
|
|
|
82
|
-
|
|
209
|
+
Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks.
|
|
210
|
+
To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers) package to call asynchronous importers from the synchronous code path.
|
|
83
211
|
|
|
84
|
-
|
|
212
|
+
To enable this, pass the `Fiber` class to the `fiber` option:
|
|
85
213
|
|
|
86
|
-
|
|
214
|
+
**webpack.config.js**
|
|
87
215
|
|
|
88
216
|
```js
|
|
89
|
-
|
|
217
|
+
module.exports = {
|
|
218
|
+
module: {
|
|
219
|
+
rules: [
|
|
220
|
+
{
|
|
221
|
+
test: /\.s[ac]ss$/i,
|
|
222
|
+
use: [
|
|
223
|
+
'style-loader',
|
|
224
|
+
'css-loader',
|
|
225
|
+
{
|
|
226
|
+
loader: 'sass-loader',
|
|
227
|
+
options: {
|
|
228
|
+
implementation: require('sass'),
|
|
229
|
+
fiber: require('fibers'),
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### `data`
|
|
240
|
+
|
|
241
|
+
Type: `String|Function`
|
|
242
|
+
Default: `undefined`
|
|
243
|
+
|
|
244
|
+
Prepends `Sass`/`SCSS` code before the actual entry file.
|
|
245
|
+
In this case, the `sass-loader` will not override the `data` option but just append the entry's content.
|
|
246
|
+
|
|
247
|
+
This is especially useful when some of your Sass variables depend on the environment:
|
|
90
248
|
|
|
249
|
+
> ℹ Since you're injecting code, this will break the source mappings in your entry file. Often there's a simpler solution than this, like multiple Sass entry files.
|
|
250
|
+
|
|
251
|
+
#### `String`
|
|
252
|
+
|
|
253
|
+
```js
|
|
91
254
|
module.exports = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
chunkFilename: "[id].css"
|
|
110
|
-
})
|
|
111
|
-
]
|
|
255
|
+
module: {
|
|
256
|
+
rules: [
|
|
257
|
+
{
|
|
258
|
+
test: /\.s[ac]ss$/i,
|
|
259
|
+
use: [
|
|
260
|
+
'style-loader',
|
|
261
|
+
'css-loader',
|
|
262
|
+
{
|
|
263
|
+
loader: 'sass-loader',
|
|
264
|
+
options: {
|
|
265
|
+
data: '$env: ' + process.env.NODE_ENV + ';',
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
112
272
|
};
|
|
113
273
|
```
|
|
114
274
|
|
|
115
|
-
|
|
275
|
+
#### `Function`
|
|
116
276
|
|
|
117
|
-
|
|
277
|
+
```js
|
|
278
|
+
module.exports = {
|
|
279
|
+
module: {
|
|
280
|
+
rules: [
|
|
281
|
+
{
|
|
282
|
+
test: /\.s[ac]ss$/i,
|
|
283
|
+
use: [
|
|
284
|
+
'style-loader',
|
|
285
|
+
'css-loader',
|
|
286
|
+
{
|
|
287
|
+
loader: 'sass-loader',
|
|
288
|
+
options: {
|
|
289
|
+
data: (loaderContext) => {
|
|
290
|
+
// More information about avalaible options https://webpack.js.org/api/loaders/
|
|
291
|
+
const { resourcePath, rootContext } = loaderContext;
|
|
292
|
+
const relativePath = path.relative(rootContext, resourcePath);
|
|
293
|
+
|
|
294
|
+
if (relativePath === 'styles/foo.scss') {
|
|
295
|
+
return '$value: 100px;';
|
|
296
|
+
}
|
|
118
297
|
|
|
119
|
-
|
|
298
|
+
return '$value: 200px;';
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
```
|
|
120
308
|
|
|
121
|
-
|
|
122
|
-
|
|
309
|
+
### `sourceMap`
|
|
310
|
+
|
|
311
|
+
Type: `Boolean`
|
|
312
|
+
Default: `false`
|
|
313
|
+
|
|
314
|
+
Enables/Disables generation of source maps.
|
|
315
|
+
|
|
316
|
+
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not).
|
|
317
|
+
|
|
318
|
+
**webpack.config.js**
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
module.exports = {
|
|
322
|
+
module: {
|
|
323
|
+
rules: [
|
|
324
|
+
{
|
|
325
|
+
test: /\.s[ac]ss$/i,
|
|
326
|
+
use: [
|
|
327
|
+
'style-loader',
|
|
328
|
+
{
|
|
329
|
+
loader: 'css-loader',
|
|
330
|
+
options: {
|
|
331
|
+
sourceMap: true,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
loader: 'sass-loader',
|
|
336
|
+
options: {
|
|
337
|
+
sourceMap: true,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
};
|
|
123
345
|
```
|
|
124
346
|
|
|
125
|
-
|
|
347
|
+
> ℹ In some rare case `node-sass` can output invalid source maps (it is `node-sass` bug), to avoid try to update node-sass to latest version or you can try to set the `outputStyle` option to `compressed` value.
|
|
126
348
|
|
|
127
|
-
###
|
|
349
|
+
### `webpackImporter`
|
|
128
350
|
|
|
129
|
-
|
|
351
|
+
Type: `Boolean`
|
|
352
|
+
Default: `true`
|
|
130
353
|
|
|
131
|
-
|
|
132
|
-
- If you pass the generated CSS on to the css-loader, all urls must be relative to the entry-file (e.g. `main.scss`).
|
|
354
|
+
Allows to disable default `webpack` importer.
|
|
133
355
|
|
|
134
|
-
|
|
356
|
+
This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starts with `~` will not work, but you can pass own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).
|
|
135
357
|
|
|
136
|
-
|
|
137
|
-
- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`. Check out [this working bootstrap example](https://github.com/webpack-contrib/sass-loader/tree/master/test/bootstrapSass).
|
|
358
|
+
**webpack.config.js**
|
|
138
359
|
|
|
139
|
-
|
|
360
|
+
```js
|
|
361
|
+
module.exports = {
|
|
362
|
+
module: {
|
|
363
|
+
rules: [
|
|
364
|
+
{
|
|
365
|
+
test: /\.s[ac]ss$/i,
|
|
366
|
+
use: [
|
|
367
|
+
'style-loader',
|
|
368
|
+
'css-loader',
|
|
369
|
+
{
|
|
370
|
+
loader: 'sass-loader',
|
|
371
|
+
options: {
|
|
372
|
+
webpackImporter: false,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Examples
|
|
383
|
+
|
|
384
|
+
### Extracts CSS into separate files
|
|
140
385
|
|
|
141
|
-
|
|
386
|
+
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
|
|
142
387
|
|
|
143
388
|
There are two possibilities to extract a style sheet from the bundle:
|
|
144
389
|
|
|
390
|
+
- [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) (use this, when using webpack 4 configuration. Works in all use-cases)
|
|
145
391
|
- [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
|
|
146
|
-
- [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) (more complex, but works in all use-cases)
|
|
147
392
|
|
|
148
|
-
|
|
393
|
+
**webpack.config.js**
|
|
149
394
|
|
|
150
|
-
|
|
395
|
+
```js
|
|
396
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
151
397
|
|
|
152
|
-
```javascript
|
|
153
398
|
module.exports = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
399
|
+
module: {
|
|
400
|
+
rules: [
|
|
401
|
+
{
|
|
402
|
+
test: /\.s[ac]ss$/i,
|
|
403
|
+
use: [
|
|
404
|
+
// fallback to style-loader in development
|
|
405
|
+
process.env.NODE_ENV !== 'production'
|
|
406
|
+
? 'style-loader'
|
|
407
|
+
: MiniCssExtractPlugin.loader,
|
|
408
|
+
'css-loader',
|
|
409
|
+
'sass-loader',
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
plugins: [
|
|
415
|
+
new MiniCssExtractPlugin({
|
|
416
|
+
// Options similar to the same options in webpackOptions.output
|
|
417
|
+
// both options are optional
|
|
418
|
+
filename: '[name].css',
|
|
419
|
+
chunkFilename: '[id].css',
|
|
420
|
+
}),
|
|
421
|
+
],
|
|
172
422
|
};
|
|
173
423
|
```
|
|
174
424
|
|
|
175
|
-
|
|
425
|
+
### Source maps
|
|
176
426
|
|
|
177
|
-
|
|
427
|
+
To enable CSS source maps, you'll need to pass the `sourceMap` option to the sass-loader _and_ the css-loader.
|
|
178
428
|
|
|
179
|
-
|
|
429
|
+
**webpack.config.js**
|
|
180
430
|
|
|
181
431
|
```javascript
|
|
182
|
-
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
432
|
+
module.exports = {
|
|
433
|
+
devtool: 'source-map', // any "source-map"-like devtool is possible
|
|
434
|
+
module: {
|
|
435
|
+
rules: [
|
|
436
|
+
{
|
|
437
|
+
test: /\.scss$/,
|
|
438
|
+
use: [
|
|
439
|
+
'style-loader',
|
|
440
|
+
{
|
|
441
|
+
loader: 'css-loader',
|
|
442
|
+
options: {
|
|
443
|
+
sourceMap: true,
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
loader: 'sass-loader',
|
|
448
|
+
options: {
|
|
449
|
+
sourceMap: true,
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
},
|
|
456
|
+
};
|
|
188
457
|
```
|
|
189
458
|
|
|
190
|
-
|
|
459
|
+
If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/master/test) for a running example.
|
|
191
460
|
|
|
192
|
-
|
|
461
|
+
## Contributing
|
|
193
462
|
|
|
194
|
-
|
|
195
|
-
<tr>
|
|
196
|
-
<td align="center">
|
|
197
|
-
<a href="https://github.com/jhnns"><img width="150" height="150" src="https://avatars0.githubusercontent.com/u/781746?v=3"></a><br>
|
|
198
|
-
<a href="https://github.com/jhnns">Johannes Ewald</a>
|
|
199
|
-
</td>
|
|
200
|
-
<td align="center">
|
|
201
|
-
<a href="https://github.com/webpack-contrib"><img width="150" height="150" src="https://avatars1.githubusercontent.com/u/1243901?v=3&s=460"></a><br>
|
|
202
|
-
<a href="https://github.com/webpack-contrib">Jorik Tangelder</a>
|
|
203
|
-
</td>
|
|
204
|
-
<td align="center">
|
|
205
|
-
<a href="https://github.com/akiran"><img width="150" height="150" src="https://avatars1.githubusercontent.com/u/3403295?v=3"></a><br>
|
|
206
|
-
<a href="https://github.com/akiran">Kiran</a>
|
|
207
|
-
</td>
|
|
208
|
-
<tr>
|
|
209
|
-
</table>
|
|
463
|
+
Please take a moment to read our contributing guidelines if you haven't yet done so.
|
|
210
464
|
|
|
465
|
+
[CONTRIBUTING](./.github/CONTRIBUTING.md)
|
|
211
466
|
|
|
212
|
-
|
|
467
|
+
## License
|
|
213
468
|
|
|
214
|
-
[MIT](
|
|
469
|
+
[MIT](./LICENSE)
|
|
215
470
|
|
|
216
471
|
[npm]: https://img.shields.io/npm/v/sass-loader.svg
|
|
217
|
-
[npm-stats]: https://img.shields.io/npm/dm/sass-loader.svg
|
|
218
472
|
[npm-url]: https://npmjs.com/package/sass-loader
|
|
219
|
-
|
|
220
473
|
[node]: https://img.shields.io/node/v/sass-loader.svg
|
|
221
474
|
[node-url]: https://nodejs.org
|
|
222
|
-
|
|
223
475
|
[deps]: https://david-dm.org/webpack-contrib/sass-loader.svg
|
|
224
476
|
[deps-url]: https://david-dm.org/webpack-contrib/sass-loader
|
|
225
|
-
|
|
226
|
-
[
|
|
227
|
-
[travis-url]: https://travis-ci.org/webpack-contrib/sass-loader
|
|
228
|
-
|
|
229
|
-
[appveyor-url]: https://ci.appveyor.com/project/webpack-contrib/sass-loader/branch/master
|
|
230
|
-
[appveyor]: https://ci.appveyor.com/api/projects/status/rqpy1vaovh20ttxs/branch/master?svg=true
|
|
231
|
-
|
|
477
|
+
[tests]: https://dev.azure.com/webpack-contrib/sass-loader/_apis/build/status/webpack-contrib.sass-loader?branchName=master
|
|
478
|
+
[tests-url]: https://dev.azure.com/webpack-contrib/sass-loader/_build/latest?definitionId=21&branchName=master
|
|
232
479
|
[cover]: https://codecov.io/gh/webpack-contrib/sass-loader/branch/master/graph/badge.svg
|
|
233
480
|
[cover-url]: https://codecov.io/gh/webpack-contrib/sass-loader
|
|
234
|
-
|
|
235
481
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
236
482
|
[chat-url]: https://gitter.im/webpack/webpack
|
|
483
|
+
[size]: https://packagephobia.now.sh/badge?p=css-loader
|
|
484
|
+
[size-url]: https://packagephobia.now.sh/result?p=css-loader
|