You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -107,19 +107,44 @@ Thankfully there are a two solutions to this problem:
107
107
108
108
## Options
109
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)
110
+
### `implementation`
111
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.
112
+
The special `implementation` option determines which implementation of Sass to use.
116
113
117
-
There is a slight difference between the `node-sass` and `sass` options. We recommend look documentation before used them:
114
+
By default the loader resolve the implementation based on your dependencies.
115
+
Just add required implementation to `package.json` (`node-sass` or `sass` package) and install dependencies.
118
116
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.
117
+
Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
121
118
122
-
**webpack.config.js**
119
+
**package.json**
120
+
121
+
```json
122
+
{
123
+
"devDependencies": {
124
+
"sass-loader": "^7.2.0",
125
+
"sass": "^1.22.10"
126
+
}
127
+
}
128
+
```
129
+
130
+
Example where the `sass-loader` loader uses the `node-sass` implementation:
131
+
132
+
**package.json**
133
+
134
+
```json
135
+
{
136
+
"devDependencies": {
137
+
"sass-loader": "^7.2.0",
138
+
"node-sass": "^4.0.0"
139
+
}
140
+
}
141
+
```
142
+
143
+
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.
144
+
145
+
It takes either `node-sass` or `sass` (`Dart Sass`) module.
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.
172
+
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.
173
+
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.
153
174
154
-
Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
175
+
We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package (setup `sassOptions.fiber`) if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package).
155
176
156
177
**package.json**
157
178
158
179
```json
159
180
{
160
181
"devDependencies": {
161
182
"sass-loader": "^7.2.0",
162
-
"sass": "^1.22.10"
183
+
"sass": "^1.22.10",
184
+
"fibers": "^4.0.1"
163
185
}
164
186
}
165
187
```
166
188
167
-
Example where the `sass-loader` loader uses the `node-sass` implementation:
189
+
You can disable automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package pass the `false` value for the `sassOptions.fiber` option.
168
190
169
-
**package.json**
191
+
**webpack.config.js**
170
192
171
-
```json
172
-
{
173
-
"devDependencies": {
174
-
"sass-loader": "^7.2.0",
175
-
"node-sass": "^4.0.0"
176
-
}
177
-
}
193
+
```js
194
+
module.exports= {
195
+
module: {
196
+
rules: [
197
+
{
198
+
test:/\.s[ac]ss$/i,
199
+
use: [
200
+
'style-loader',
201
+
'css-loader',
202
+
{
203
+
loader:'sass-loader',
204
+
options: {
205
+
implementation:require('sass'),
206
+
sassOptions: {
207
+
fiber:false,
208
+
},
209
+
},
210
+
},
211
+
],
212
+
},
213
+
],
214
+
},
215
+
};
178
216
```
179
217
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.
218
+
Also you can pass own the `fiber` value using this code:
181
219
182
-
It takes either `node-sass` or `sass` (`Dart Sass`) module.
183
-
184
-
For example, to use Dart Sass, you'd pass:
220
+
**webpack.config.js**
185
221
186
222
```js
187
223
module.exports= {
@@ -195,8 +231,10 @@ module.exports = {
195
231
{
196
232
loader:'sass-loader',
197
233
options: {
198
-
// Prefer `dart-sass`
199
234
implementation:require('sass'),
235
+
sassOptions: {
236
+
fiber:require('fibers'),
237
+
},
200
238
},
201
239
},
202
240
],
@@ -206,10 +244,27 @@ module.exports = {
206
244
};
207
245
```
208
246
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.
247
+
### `sassOptions`
248
+
249
+
Type: `Object|Function`
250
+
251
+
Options for [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass) implementation.
252
+
253
+
> ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
254
+
255
+
> ℹ️ Options such as `file` and `outFile` are unavailable.
256
+
257
+
> ℹ We recommend don't use `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because loader automatically setup this options.
258
+
259
+
There is a slight difference between the `node-sass` and `sass` (`Dart Sass`) options.
260
+
We recommend look documentation before used them:
261
+
262
+
-[the Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options.
263
+
-[the Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api) for all available `sass` options.
264
+
265
+
#### `Object`
211
266
212
-
To enable this, pass the `Fiber` class to the `fiber` option:
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not).
413
+
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option, all values enable source map generation except `eval` and `false` value.
317
414
318
415
**webpack.config.js**
319
416
@@ -351,7 +448,7 @@ module.exports = {
351
448
Type: `Boolean`
352
449
Default: `true`
353
450
354
-
Allows to disable default `webpack` importer.
451
+
Enables/Disables default `webpack` importer.
355
452
356
453
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)).
357
454
@@ -424,6 +521,8 @@ module.exports = {
424
521
425
522
### Source maps
426
523
524
+
Enables/Disables generation of source maps.
525
+
427
526
To enable CSS source maps, you'll need to pass the `sourceMap` option to the sass-loader _and_ the css-loader.
0 commit comments