sass-loader 7.3.0 → 8.0.2

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 CHANGED
@@ -2,6 +2,52 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [8.0.2](https://github.com/webpack-contrib/sass-loader/compare/v8.0.1...v8.0.2) (2020-01-13)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * compatibility with node@8 ([#798](https://github.com/webpack-contrib/sass-loader/issues/798)) ([6f3852f](https://github.com/webpack-contrib/sass-loader/commit/6f3852f7d393dd0bc8f8d264d81ecc941bc72511))
11
+
12
+ ### [8.0.1](https://github.com/webpack-contrib/sass-loader/compare/v8.0.0...v8.0.1) (2020-01-10)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * support webpack@5 ([#794](https://github.com/webpack-contrib/sass-loader/issues/794)) ([6c59e37](https://github.com/webpack-contrib/sass-loader/commit/6c59e37e3f67668d7a3908444ddfc0176bc5601f))
18
+
19
+ ## [8.0.0](https://github.com/webpack-contrib/sass-loader/compare/v7.3.1...v8.0.0) (2019-08-29)
20
+
21
+
22
+ ### ⚠ BREAKING CHANGES
23
+
24
+ * minimum required `webpack` version is `4.36.0`
25
+ * minimum required `node.js` version is `8.9.0`
26
+ * move all sass (`includePaths`, `importer`, `functions`, `outputStyle`) options to the `sassOptions` option. The `functions` option can't be used as `Function`, you should use `sassOption` as `Function` to achieve this.
27
+ * the `data` option was renamed to the `prependData` option
28
+ * default value of the `sourceMap` option depends on the `devtool` value (`eval`/`false` values don't enable source map generation)
29
+
30
+
31
+ ### Features
32
+
33
+ * automatically use the `fibers` package if it is possible ([#744](https://github.com/webpack-contrib/sass-loader/issues/744)) ([96184e1](https://github.com/webpack-contrib/sass-loader/commit/96184e1))
34
+ * source map generation depends on the `devtool` option ([#743](https://github.com/webpack-contrib/sass-loader/issues/743)) ([fcea88e](https://github.com/webpack-contrib/sass-loader/commit/fcea88e))
35
+ * validate loader options ([#737](https://github.com/webpack-contrib/sass-loader/issues/737)) ([7b543fc](https://github.com/webpack-contrib/sass-loader/commit/7b543fc))
36
+ * reworked error handling from `node-sass`/`sass`
37
+ * improve resolution for `@import` (including support `_index` and `index` files in a directory)
38
+
39
+ ### Bug Fixes
40
+
41
+ * compatibility with `pnp`
42
+
43
+
44
+ ### [7.3.1](https://github.com/webpack-contrib/sass-loader/compare/v7.3.0...v7.3.1) (2019-08-20)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * minimum `node` version in `package.json` ([#733](https://github.com/webpack-contrib/sass-loader/issues/733)) ([1175920](https://github.com/webpack-contrib/sass-loader/commit/1175920))
50
+
5
51
  ## [7.3.0](https://github.com/webpack-contrib/sass-loader/compare/v7.2.0...v7.3.0) (2019-08-20)
6
52
 
7
53
 
package/README.md CHANGED
@@ -27,23 +27,20 @@ To begin, you'll need to install `sass-loader`:
27
27
  npm install sass-loader node-sass webpack --save-dev
28
28
  ```
29
29
 
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).
30
+ `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 can be found below).
31
31
  This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
32
32
 
33
- - [node sass](https://github.com/sass/node-sass)
34
- - [dart sass](http://sass-lang.com/dart-sass)
33
+ 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.
35
34
 
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.
35
+ Then add the loader to your Webpack configuration. For example:
37
36
 
38
- Then add the loader to your `webpack` config. For example:
39
-
40
- **file.js**
37
+ **app.js**
41
38
 
42
39
  ```js
43
- import style from './style.scss';
40
+ import './style.scss';
44
41
  ```
45
42
 
46
- **file.scss**
43
+ **style.scss**
47
44
 
48
45
  ```scss
49
46
  $body-color: red;
@@ -75,51 +72,76 @@ module.exports = {
75
72
  };
76
73
  ```
77
74
 
78
- And run `webpack` via your preferred method.
75
+ Finally run `webpack` via your preferred method.
79
76
 
80
77
  ### Resolving `import` at-rules
81
78
 
82
- The webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).
79
+ Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).
83
80
 
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:
81
+ 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
82
 
86
- ```css
83
+ ```scss
87
84
  @import '~bootstrap';
88
85
  ```
89
86
 
90
87
  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";`
88
+ Webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files.
89
+ Writing `@import "style.scss"` is the same as `@import "./style.scss";`
93
90
 
94
91
  ### Problems with `url(...)`
95
92
 
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.
93
+ 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
94
 
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.
95
+ - If you pass the generated CSS on to the `css-loader`, all urls must be relative to the entry-file (e.g. `main.scss`).
96
+ - If you're just generating CSS without passing it to the `css-loader`, it must be relative to your web root.
100
97
 
101
98
  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
99
 
103
100
  Thankfully there are a two solutions to this problem:
104
101
 
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.
102
+ - Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before `sass-loader` in the loader chain.
106
103
  - 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
104
 
108
105
  ## Options
109
106
 
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)
107
+ ### `implementation`
111
108
 
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.
109
+ The special `implementation` option determines which implementation of Sass to use.
116
110
 
117
- There is a slight difference between the `node-sass` and `sass` options. We recommend look documentation before used them:
111
+ By default the loader resolve the implementation based on your dependencies.
112
+ Just add required implementation to `package.json` (`node-sass` or `sass` package) and install dependencies.
118
113
 
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.
114
+ Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
121
115
 
122
- **webpack.config.js**
116
+ **package.json**
117
+
118
+ ```json
119
+ {
120
+ "devDependencies": {
121
+ "sass-loader": "^7.2.0",
122
+ "sass": "^1.22.10"
123
+ }
124
+ }
125
+ ```
126
+
127
+ Example where the `sass-loader` loader uses the `node-sass` implementation:
128
+
129
+ **package.json**
130
+
131
+ ```json
132
+ {
133
+ "devDependencies": {
134
+ "sass-loader": "^7.2.0",
135
+ "node-sass": "^4.0.0"
136
+ }
137
+ }
138
+ ```
139
+
140
+ Beware the situation when `node-sass` and `sass` were installed! By default the `sass-loader` prefers `node-sass`. In order to avoid this situation you can use the `implementation` option.
141
+
142
+ The `implementation` options either accepts `node-sass` or `sass` (`Dart Sass`) as a module.
143
+
144
+ For example, to use Dart Sass, you'd pass:
123
145
 
124
146
  ```js
125
147
  module.exports = {
@@ -133,8 +155,8 @@ module.exports = {
133
155
  {
134
156
  loader: 'sass-loader',
135
157
  options: {
136
- indentWidth: 4,
137
- includePaths: ['absolute/path/a', 'absolute/path/b'],
158
+ // Prefer `dart-sass`
159
+ implementation: require('sass'),
138
160
  },
139
161
  },
140
162
  ],
@@ -144,14 +166,10 @@ module.exports = {
144
166
  };
145
167
  ```
146
168
 
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.
169
+ 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.
170
+ 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
171
 
154
- Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
172
+ 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
173
 
156
174
  **package.json**
157
175
 
@@ -159,29 +177,44 @@ Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementat
159
177
  {
160
178
  "devDependencies": {
161
179
  "sass-loader": "^7.2.0",
162
- "sass": "^1.22.10"
180
+ "sass": "^1.22.10",
181
+ "fibers": "^4.0.1"
163
182
  }
164
183
  }
165
184
  ```
166
185
 
167
- Example where the `sass-loader` loader uses the `node-sass` implementation:
186
+ You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers) package by passing a `false` value for the `sassOptions.fiber` option.
168
187
 
169
- **package.json**
188
+ **webpack.config.js**
170
189
 
171
- ```json
172
- {
173
- "devDependencies": {
174
- "sass-loader": "^7.2.0",
175
- "node-sass": "^4.0.0"
176
- }
177
- }
190
+ ```js
191
+ module.exports = {
192
+ module: {
193
+ rules: [
194
+ {
195
+ test: /\.s[ac]ss$/i,
196
+ use: [
197
+ 'style-loader',
198
+ 'css-loader',
199
+ {
200
+ loader: 'sass-loader',
201
+ options: {
202
+ implementation: require('sass'),
203
+ sassOptions: {
204
+ fiber: false,
205
+ },
206
+ },
207
+ },
208
+ ],
209
+ },
210
+ ],
211
+ },
212
+ };
178
213
  ```
179
214
 
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.
215
+ You can also pass the `fiber` value using this code:
181
216
 
182
- It takes either `node-sass` or `sass` (`Dart Sass`) module.
183
-
184
- For example, to use Dart Sass, you'd pass:
217
+ **webpack.config.js**
185
218
 
186
219
  ```js
187
220
  module.exports = {
@@ -195,8 +228,10 @@ module.exports = {
195
228
  {
196
229
  loader: 'sass-loader',
197
230
  options: {
198
- // Prefer `dart-sass`
199
231
  implementation: require('sass'),
232
+ sassOptions: {
233
+ fiber: require('fibers'),
234
+ },
200
235
  },
201
236
  },
202
237
  ],
@@ -206,10 +241,27 @@ module.exports = {
206
241
  };
207
242
  ```
208
243
 
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.
244
+ ### `sassOptions`
245
+
246
+ Type: `Object|Function`
247
+
248
+ Options for [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass) implementation.
249
+
250
+ > ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
251
+
252
+ > ℹ️ Options such as `file` and `outFile` are unavailable.
253
+
254
+ > ℹ We recommend not to use the `sourceMapContents`, `sourceMapEmbed`, `sourceMapRoot` options because `sass-loader` automatically sets these options.
255
+
256
+ There is a slight difference between the `node-sass` and `sass` (`Dart Sass`) options.
257
+ Please consult documentation before using them:
258
+
259
+ - [Node Sass documentation](https://github.com/sass/node-sass/#options) for all available `node-sass` options.
260
+ - [Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api) for all available `sass` options.
261
+
262
+ #### `Object`
211
263
 
212
- To enable this, pass the `Fiber` class to the `fiber` option:
264
+ Use and object for the Sass implementation setup.
213
265
 
214
266
  **webpack.config.js**
215
267
 
@@ -225,8 +277,10 @@ module.exports = {
225
277
  {
226
278
  loader: 'sass-loader',
227
279
  options: {
228
- implementation: require('sass'),
229
- fiber: require('fibers'),
280
+ sassOptions: {
281
+ indentWidth: 4,
282
+ includePaths: ['absolute/path/a', 'absolute/path/b'],
283
+ },
230
284
  },
231
285
  },
232
286
  ],
@@ -236,7 +290,47 @@ module.exports = {
236
290
  };
237
291
  ```
238
292
 
239
- ### `data`
293
+ #### `Function`
294
+
295
+ Allows to setup the Sass implementation by setting different options based on the loader context.
296
+
297
+ ```js
298
+ module.exports = {
299
+ module: {
300
+ rules: [
301
+ {
302
+ test: /\.s[ac]ss$/i,
303
+ use: [
304
+ 'style-loader',
305
+ 'css-loader',
306
+ {
307
+ loader: 'sass-loader',
308
+ options: {
309
+ sassOptions: (loaderContext) => {
310
+ // More information about available properties https://webpack.js.org/api/loaders/
311
+ const { resourcePath, rootContext } = loaderContext;
312
+ const relativePath = path.relative(rootContext, resourcePath);
313
+
314
+ if (relativePath === 'styles/foo.scss') {
315
+ return {
316
+ includePaths: ['absolute/path/c', 'absolute/path/d'],
317
+ };
318
+ }
319
+
320
+ return {
321
+ includePaths: ['absolute/path/a', 'absolute/path/b'],
322
+ };
323
+ },
324
+ },
325
+ },
326
+ ],
327
+ },
328
+ ],
329
+ },
330
+ };
331
+ ```
332
+
333
+ ### `prependData`
240
334
 
241
335
  Type: `String|Function`
242
336
  Default: `undefined`
@@ -262,7 +356,7 @@ module.exports = {
262
356
  {
263
357
  loader: 'sass-loader',
264
358
  options: {
265
- data: '$env: ' + process.env.NODE_ENV + ';',
359
+ prependData: '$env: ' + process.env.NODE_ENV + ';',
266
360
  },
267
361
  },
268
362
  ],
@@ -286,8 +380,8 @@ module.exports = {
286
380
  {
287
381
  loader: 'sass-loader',
288
382
  options: {
289
- data: (loaderContext) => {
290
- // More information about avalaible options https://webpack.js.org/api/loaders/
383
+ prependData: (loaderContext) => {
384
+ // More information about available properties https://webpack.js.org/api/loaders/
291
385
  const { resourcePath, rootContext } = loaderContext;
292
386
  const relativePath = path.relative(rootContext, resourcePath);
293
387
 
@@ -309,11 +403,11 @@ module.exports = {
309
403
  ### `sourceMap`
310
404
 
311
405
  Type: `Boolean`
312
- Default: `false`
406
+ Default: depends on the `compiler.devtool` value
313
407
 
314
408
  Enables/Disables generation of source maps.
315
409
 
316
- They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not).
410
+ 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
411
 
318
412
  **webpack.config.js**
319
413
 
@@ -344,16 +438,42 @@ module.exports = {
344
438
  };
345
439
  ```
346
440
 
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.
441
+ > ℹ In some rare cases `node-sass` can output invalid source maps (it is a `node-sass` bug).
442
+ > In order to avoid this, you can try to update `node-sass` to latest version or you can try to set within `sassOptions` the `outputStyle` option to `compressed`.
443
+
444
+ **webpack.config.js**
445
+
446
+ ```js
447
+ module.exports = {
448
+ module: {
449
+ rules: [
450
+ {
451
+ test: /\.s[ac]ss$/i,
452
+ use: [
453
+ 'style-loader',
454
+ 'css-loader',
455
+ {
456
+ loader: 'sass-loader',
457
+ sourceMap: true,
458
+ sassOptions: {
459
+ outputStyle: 'compressed',
460
+ },
461
+ },
462
+ ],
463
+ },
464
+ ],
465
+ },
466
+ };
467
+ ```
348
468
 
349
469
  ### `webpackImporter`
350
470
 
351
471
  Type: `Boolean`
352
472
  Default: `true`
353
473
 
354
- Allows to disable default `webpack` importer.
474
+ Enables/Disables the default Webpack importer.
355
475
 
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)).
476
+ This can improve performance in some cases. Use it with caution because aliases and `@import` at-rules starting with `~` will not work. You can pass own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).
357
477
 
358
478
  **webpack.config.js**
359
479
 
@@ -424,7 +544,9 @@ module.exports = {
424
544
 
425
545
  ### Source maps
426
546
 
427
- To enable CSS source maps, you'll need to pass the `sourceMap` option to the sass-loader _and_ the css-loader.
547
+ Enables/Disables generation of source maps.
548
+
549
+ To enable CSS source maps, you'll need to pass the `sourceMap` option to the `sass-loader` _and_ the css-loader.
428
550
 
429
551
  **webpack.config.js**
430
552
 
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ class SassError extends Error {
9
+ constructor(sassError, resourcePath) {
10
+ super();
11
+ this.name = 'SassError';
12
+ this.originalSassError = sassError;
13
+ this.loc = {
14
+ line: sassError.line,
15
+ column: sassError.column
16
+ }; // Keep original error if `sassError.formatted` is unavailable
17
+
18
+ this.message = `${this.name}: ${this.originalSassError.message}`;
19
+
20
+ if (this.originalSassError.formatted) {
21
+ this.message = `${this.name}: ${this.originalSassError.formatted.replace(/^Error: /, '').replace(/(\s*)stdin(\s*)/, `$1${resourcePath}$2`)}`; // Instruct webpack to hide the JS stack from the console.
22
+ // Usually you're only interested in the SASS stack in this case.
23
+ // eslint-disable-next-line no-param-reassign
24
+
25
+ this.hideStack = true;
26
+ Error.captureStackTrace(this, this.constructor);
27
+ }
28
+ }
29
+
30
+ }
31
+
32
+ var _default = SassError;
33
+ exports.default = _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function getDefaultSassImplementation() {
9
+ let sassImplPkg = 'node-sass';
10
+
11
+ try {
12
+ require.resolve('node-sass');
13
+ } catch (error) {
14
+ try {
15
+ require.resolve('sass');
16
+
17
+ sassImplPkg = 'sass';
18
+ } catch (ignoreError) {
19
+ sassImplPkg = 'node-sass';
20
+ }
21
+ } // eslint-disable-next-line import/no-dynamic-require, global-require
22
+
23
+
24
+ return require(sassImplPkg);
25
+ }
26
+
27
+ var _default = getDefaultSassImplementation;
28
+ exports.default = _default;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _neoAsync = _interopRequireDefault(require("neo-async"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ let nodeSassJobQueue = null;
13
+ /**
14
+ * Verifies that the implementation and version of Sass is supported by this loader.
15
+ *
16
+ * @param {Object} implementation
17
+ * @returns {Function}
18
+ */
19
+
20
+ function getRenderFunctionFromSassImplementation(implementation) {
21
+ const isDartSass = implementation.info.includes('dart-sass');
22
+
23
+ if (isDartSass) {
24
+ return implementation.render.bind(implementation);
25
+ } // There is an issue with node-sass when async custom importers are used
26
+ // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360
27
+ // We need to use a job queue to make sure that one thread is always available to the UV lib
28
+
29
+
30
+ if (nodeSassJobQueue === null) {
31
+ const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
32
+ nodeSassJobQueue = _neoAsync.default.queue(implementation.render.bind(implementation), threadPoolSize - 1);
33
+ }
34
+
35
+ return nodeSassJobQueue.push.bind(nodeSassJobQueue);
36
+ }
37
+
38
+ var _default = getRenderFunctionFromSassImplementation;
39
+ exports.default = _default;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _semver = _interopRequireDefault(require("semver"));
9
+
10
+ var _getDefaultSassImplementation = _interopRequireDefault(require("./getDefaultSassImplementation"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function getSassImplementation(implementation) {
15
+ let resolvedImplementation = implementation;
16
+
17
+ if (!resolvedImplementation) {
18
+ // eslint-disable-next-line no-param-reassign
19
+ resolvedImplementation = (0, _getDefaultSassImplementation.default)();
20
+ }
21
+
22
+ const {
23
+ info
24
+ } = resolvedImplementation;
25
+
26
+ if (!info) {
27
+ throw new Error('Unknown Sass implementation.');
28
+ }
29
+
30
+ const infoParts = info.split('\t');
31
+
32
+ if (infoParts.length < 2) {
33
+ throw new Error(`Unknown Sass implementation "${info}".`);
34
+ }
35
+
36
+ const [implementationName, version] = infoParts;
37
+
38
+ if (implementationName === 'dart-sass') {
39
+ if (!_semver.default.satisfies(version, '^1.3.0')) {
40
+ throw new Error(`Dart Sass version ${version} is incompatible with ^1.3.0.`);
41
+ }
42
+
43
+ return resolvedImplementation;
44
+ } else if (implementationName === 'node-sass') {
45
+ if (!_semver.default.satisfies(version, '^4.0.0')) {
46
+ throw new Error(`Node Sass version ${version} is incompatible with ^4.0.0.`);
47
+ }
48
+
49
+ return resolvedImplementation;
50
+ }
51
+
52
+ throw new Error(`Unknown Sass implementation "${implementationName}".`);
53
+ }
54
+
55
+ var _default = getSassImplementation;
56
+ exports.default = _default;
@@ -21,44 +21,53 @@ function isProductionLikeMode(loaderContext) {
21
21
  /**
22
22
  * Derives the sass options from the loader context and normalizes its values with sane defaults.
23
23
  *
24
- * Please note: If loaderContext.query is an options object, it will be re-used across multiple invocations.
25
- * That's why we must not modify the object directly.
26
- *
27
- * @param {LoaderContext} loaderContext
28
- * @param {string} loaderOptions
29
- * @param {object} content
24
+ * @param {object} loaderContext
25
+ * @param {object} loaderOptions
26
+ * @param {string} content
27
+ * @param {object} implementation
30
28
  * @returns {Object}
31
29
  */
32
30
 
33
31
 
34
- function getSassOptions(loaderContext, loaderOptions, content) {
35
- const options = (0, _cloneDeep.default)(loaderOptions);
36
- const {
37
- resourcePath
38
- } = loaderContext; // allow opt.functions to be configured WRT loaderContext
32
+ function getSassOptions(loaderContext, loaderOptions, content, implementation) {
33
+ const options = (0, _cloneDeep.default)(loaderOptions.sassOptions ? typeof loaderOptions.sassOptions === 'function' ? loaderOptions.sassOptions(loaderContext) || {} : loaderOptions.sassOptions : {});
34
+ const isDartSass = implementation.info.includes('dart-sass');
39
35
 
40
- if (typeof options.functions === 'function') {
41
- options.functions = options.functions(loaderContext);
42
- }
36
+ if (isDartSass) {
37
+ const shouldTryToResolveFibers = !options.fiber && options.fiber !== false;
43
38
 
44
- let {
45
- data
46
- } = options;
39
+ if (shouldTryToResolveFibers) {
40
+ let fibers;
47
41
 
48
- if (typeof options.data === 'function') {
49
- data = options.data(loaderContext);
42
+ try {
43
+ fibers = require.resolve('fibers');
44
+ } catch (_error) {// Nothing
45
+ }
46
+
47
+ if (fibers) {
48
+ // eslint-disable-next-line global-require, import/no-dynamic-require
49
+ options.fiber = require(fibers);
50
+ }
51
+ } else if (options.fiber === false) {
52
+ // Don't pass the `fiber` option for `sass` (`Dart Sass`)
53
+ delete options.fiber;
54
+ }
55
+ } else {
56
+ // Don't pass the `fiber` option for `node-sass`
57
+ delete options.fiber;
50
58
  }
51
59
 
52
- options.data = data ? data + _os.default.EOL + content : content; // opt.outputStyle
60
+ options.data = loaderOptions.prependData ? typeof loaderOptions.prependData === 'function' ? loaderOptions.prependData(loaderContext) + _os.default.EOL + content : loaderOptions.prependData + _os.default.EOL + content : content; // opt.outputStyle
53
61
 
54
62
  if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
55
63
  options.outputStyle = 'compressed';
56
- } // opt.sourceMap
64
+ }
65
+
66
+ const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap; // opt.sourceMap
57
67
  // Not using the `this.sourceMap` flag because css source maps are different
58
68
  // @see https://github.com/webpack/css-loader/pull/40
59
69
 
60
-
61
- if (options.sourceMap) {
70
+ if (useSourceMap) {
62
71
  // Deliberately overriding the sourceMap option here.
63
72
  // node-sass won't produce source maps if the data option is used and options.sourceMap is not a string.
64
73
  // In case it is a string, options.sourceMap should be a path where the source map is written.
@@ -82,8 +91,11 @@ function getSassOptions(loaderContext, loaderOptions, content) {
82
91
  // when exported by webpack-extract-text-plugin.
83
92
  options.sourceMapContents = true;
84
93
  }
85
- } // indentedSyntax is a boolean flag.
94
+ }
86
95
 
96
+ const {
97
+ resourcePath
98
+ } = loaderContext;
87
99
 
88
100
  const ext = _path.default.extname(resourcePath); // If we are compiling sass and indentedSyntax isn't set, automatically set it.
89
101
 
@@ -95,10 +107,8 @@ function getSassOptions(loaderContext, loaderOptions, content) {
95
107
  } // Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s.
96
108
 
97
109
 
98
- options.importer = options.importer ? (0, _proxyCustomImporters.default)(options.importer, resourcePath) : []; // `node-sass` uses `includePaths` to resolve `@import` paths. Append the currently processed file.
99
-
100
- options.includePaths = options.includePaths || [];
101
- options.includePaths.push(_path.default.dirname(resourcePath));
110
+ options.importer = options.importer ? (0, _proxyCustomImporters.default)(options.importer, resourcePath) : [];
111
+ options.includePaths = (options.includePaths || []).concat(_path.default.dirname(resourcePath));
102
112
  return options;
103
113
  }
104
114
 
@@ -34,7 +34,7 @@ function importsToResolve(url) {
34
34
  // @see https://github.com/webpack-contrib/sass-loader/issues/167
35
35
 
36
36
 
37
- const ext = _path.default.extname(request); // In case there is module request, send this to webpack resolver
37
+ const ext = _path.default.extname(request).toLowerCase(); // In case there is module request, send this to webpack resolver
38
38
 
39
39
 
40
40
  if (matchModuleImport.test(url)) {
@@ -71,7 +71,7 @@ function importsToResolve(url) {
71
71
  // 3. Send the original url to webpack resolver, maybe it's alias.
72
72
 
73
73
 
74
- if (basename.charAt(0) === '_') {
74
+ if (basename.startsWith('_')) {
75
75
  return [`${request}.scss`, `${request}.sass`, `${request}.css`, request, url];
76
76
  } // In case there is no file extension and filename doesn't start with `_`:
77
77
  //
package/dist/index.js CHANGED
@@ -7,66 +7,53 @@ exports.default = void 0;
7
7
 
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
 
10
- var _neoAsync = _interopRequireDefault(require("neo-async"));
10
+ var _schemaUtils = _interopRequireDefault(require("schema-utils"));
11
11
 
12
- var _pify = _interopRequireDefault(require("pify"));
12
+ var _loaderUtils = require("loader-utils");
13
13
 
14
- var _semver = _interopRequireDefault(require("semver"));
14
+ var _options = _interopRequireDefault(require("./options.json"));
15
15
 
16
- var _loaderUtils = require("loader-utils");
16
+ var _getSassImplementation = _interopRequireDefault(require("./getSassImplementation"));
17
17
 
18
- var _formatSassError = _interopRequireDefault(require("./formatSassError"));
18
+ var _getSassOptions = _interopRequireDefault(require("./getSassOptions"));
19
19
 
20
20
  var _webpackImporter = _interopRequireDefault(require("./webpackImporter"));
21
21
 
22
- var _getSassOptions = _interopRequireDefault(require("./getSassOptions"));
22
+ var _getRenderFunctionFromSassImplementation = _interopRequireDefault(require("./getRenderFunctionFromSassImplementation"));
23
23
 
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ var _SassError = _interopRequireDefault(require("./SassError"));
25
25
 
26
- let nodeSassJobQueue = null; // Very hacky check
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
- function hasGetResolve(loaderContext) {
29
- return loaderContext.getResolve && // eslint-disable-next-line no-underscore-dangle
30
- loaderContext._compiler && // eslint-disable-next-line no-underscore-dangle
31
- loaderContext._compiler.resolverFactory && // eslint-disable-next-line no-underscore-dangle
32
- loaderContext._compiler.resolverFactory._create && /cachedCleverMerge/.test( // eslint-disable-next-line no-underscore-dangle
33
- loaderContext._compiler.resolverFactory._create.toString());
34
- }
35
28
  /**
36
29
  * The sass-loader makes node-sass and dart-sass available to webpack modules.
37
30
  *
38
- * @this {LoaderContext}
31
+ * @this {object}
39
32
  * @param {string} content
40
33
  */
41
-
42
-
43
34
  function loader(content) {
44
35
  const options = (0, _loaderUtils.getOptions)(this) || {};
36
+ (0, _schemaUtils.default)(_options.default, options, {
37
+ name: 'Sass Loader',
38
+ baseDataPath: 'options'
39
+ });
40
+ const implementation = (0, _getSassImplementation.default)(options.implementation);
45
41
  const callback = this.async();
46
42
 
47
43
  const addNormalizedDependency = file => {
48
44
  // node-sass returns POSIX paths
49
- this.dependency(_path.default.normalize(file));
45
+ this.addDependency(_path.default.normalize(file));
50
46
  };
51
47
 
52
- if (typeof callback !== 'function') {
53
- throw new Error('Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/sass-loader/issues/333');
54
- }
55
-
56
- let resolve = (0, _pify.default)(this.resolve); // Supported since v4.36.0
48
+ const sassOptions = (0, _getSassOptions.default)(this, options, content, implementation);
49
+ const shouldUseWebpackImporter = typeof options.webpackImporter === 'boolean' ? options.webpackImporter : true;
57
50
 
58
- if (hasGetResolve(this)) {
59
- resolve = this.getResolve({
51
+ if (shouldUseWebpackImporter) {
52
+ const resolve = this.getResolve({
60
53
  mainFields: ['sass', 'style', 'main', '...'],
61
54
  mainFiles: ['_index', 'index', '...'],
62
55
  extensions: ['.scss', '.sass', '.css', '...']
63
56
  });
64
- }
65
-
66
- const sassOptions = (0, _getSassOptions.default)(this, options, content);
67
- const shouldUseWebpackImporter = typeof options.webpackImporter === 'boolean' ? options.webpackImporter : true;
68
-
69
- if (shouldUseWebpackImporter) {
70
57
  sassOptions.importer.push((0, _webpackImporter.default)(this.resourcePath, resolve, addNormalizedDependency));
71
58
  } // Skip empty files, otherwise it will stop webpack, see issue #21
72
59
 
@@ -76,17 +63,14 @@ function loader(content) {
76
63
  return;
77
64
  }
78
65
 
79
- const render = getRenderFuncFromSassImpl( // eslint-disable-next-line import/no-extraneous-dependencies, global-require
80
- options.implementation || getDefaultSassImpl());
66
+ const render = (0, _getRenderFunctionFromSassImplementation.default)(implementation);
81
67
  render(sassOptions, (error, result) => {
82
68
  if (error) {
83
- (0, _formatSassError.default)(error, this.resourcePath);
84
-
85
69
  if (error.file) {
86
- this.dependency(error.file);
70
+ addNormalizedDependency(error.file);
87
71
  }
88
72
 
89
- callback(error);
73
+ callback(new _SassError.default(error, this.resourcePath));
90
74
  return;
91
75
  }
92
76
 
@@ -102,7 +86,7 @@ function loader(content) {
102
86
  // we know that this path is relative to process.cwd(). This is how node-sass works.
103
87
  // eslint-disable-next-line no-param-reassign
104
88
 
105
- const stdinIndex = result.map.sources.findIndex(source => source.indexOf('stdin') !== -1);
89
+ const stdinIndex = result.map.sources.findIndex(source => source.includes('stdin'));
106
90
 
107
91
  if (stdinIndex !== -1) {
108
92
  // eslint-disable-next-line no-param-reassign
@@ -125,78 +109,6 @@ function loader(content) {
125
109
  callback(null, result.css.toString(), result.map);
126
110
  });
127
111
  }
128
- /**
129
- * Verifies that the implementation and version of Sass is supported by this loader.
130
- *
131
- * @param {Object} module
132
- * @returns {Function}
133
- */
134
-
135
-
136
- function getRenderFuncFromSassImpl(module) {
137
- const {
138
- info
139
- } = module;
140
-
141
- if (!info) {
142
- throw new Error('Unknown Sass implementation.');
143
- }
144
-
145
- const components = info.split('\t');
146
-
147
- if (components.length < 2) {
148
- throw new Error(`Unknown Sass implementation "${info}".`);
149
- }
150
-
151
- const [implementation, version] = components;
152
-
153
- if (!_semver.default.valid(version)) {
154
- throw new Error(`Invalid Sass version "${version}".`);
155
- }
156
-
157
- if (implementation === 'dart-sass') {
158
- if (!_semver.default.satisfies(version, '^1.3.0')) {
159
- throw new Error(`Dart Sass version ${version} is incompatible with ^1.3.0.`);
160
- }
161
-
162
- return module.render.bind(module);
163
- } else if (implementation === 'node-sass') {
164
- if (!_semver.default.satisfies(version, '^4.0.0')) {
165
- throw new Error(`Node Sass version ${version} is incompatible with ^4.0.0.`);
166
- } // There is an issue with node-sass when async custom importers are used
167
- // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360
168
- // We need to use a job queue to make sure that one thread is always available to the UV lib
169
-
170
-
171
- if (nodeSassJobQueue === null) {
172
- const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);
173
- nodeSassJobQueue = _neoAsync.default.queue(module.render.bind(module), threadPoolSize - 1);
174
- }
175
-
176
- return nodeSassJobQueue.push.bind(nodeSassJobQueue);
177
- }
178
-
179
- throw new Error(`Unknown Sass implementation "${implementation}".`);
180
- }
181
-
182
- function getDefaultSassImpl() {
183
- let sassImplPkg = 'node-sass';
184
-
185
- try {
186
- require.resolve('node-sass');
187
- } catch (error) {
188
- try {
189
- require.resolve('sass');
190
-
191
- sassImplPkg = 'sass';
192
- } catch (ignoreError) {
193
- sassImplPkg = 'node-sass';
194
- }
195
- } // eslint-disable-next-line import/no-dynamic-require, global-require
196
-
197
-
198
- return require(sassImplPkg);
199
- }
200
112
 
201
113
  var _default = loader;
202
114
  exports.default = _default;
@@ -0,0 +1,41 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "implementation": {
5
+ "description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation).",
6
+ "type": "object"
7
+ },
8
+ "sassOptions": {
9
+ "description": "Options for `node-sass` or `sass` (`Dart Sass`) implementation. (https://github.com/webpack-contrib/sass-loader#implementation).",
10
+ "anyOf": [
11
+ {
12
+ "type": "object",
13
+ "additionalProperties": true
14
+ },
15
+ {
16
+ "instanceof": "Function"
17
+ }
18
+ ]
19
+ },
20
+ "prependData": {
21
+ "description": "Prepends `Sass`/`SCSS` code before the actual entry file (https://github.com/webpack-contrib/sass-loader#prependdata).",
22
+ "anyOf": [
23
+ {
24
+ "type": "string"
25
+ },
26
+ {
27
+ "instanceof": "Function"
28
+ }
29
+ ]
30
+ },
31
+ "sourceMap": {
32
+ "description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/sass-loader#sourcemap).",
33
+ "type": "boolean"
34
+ },
35
+ "webpackImporter": {
36
+ "description": "Enables/Disables default `webpack` importer (https://github.com/webpack-contrib/sass-loader#webpackimporter).",
37
+ "type": "boolean"
38
+ }
39
+ },
40
+ "additionalProperties": false
41
+ }
@@ -26,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
26
  * @param {string} prev
27
27
  * @param {Function<Error, string>} done
28
28
  */
29
- const matchCss = /\.css$/;
29
+ const matchCss = /\.css$/i;
30
30
  /**
31
31
  * Returns an importer that uses webpack's resolving algorithm.
32
32
  *
package/package.json CHANGED
@@ -1,88 +1,103 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "7.3.0",
3
+ "version": "8.0.2",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
7
7
  "author": "J. Tangelder",
8
8
  "homepage": "https://github.com/webpack-contrib/sass-loader",
9
9
  "bugs": "https://github.com/webpack-contrib/sass-loader/issues",
10
+ "funding": {
11
+ "type": "opencollective",
12
+ "url": "https://opencollective.com/webpack"
13
+ },
10
14
  "main": "dist/cjs.js",
11
15
  "engines": {
12
16
  "node": ">= 8.9.0"
13
17
  },
14
18
  "scripts": {
15
19
  "start": "npm run build -- -w",
16
- "prebuild": "npm run clean",
17
- "build": "cross-env NODE_ENV=production babel src -d dist --ignore \"src/**/*.test.js\" --copy-files",
18
20
  "clean": "del-cli dist",
21
+ "prebuild": "npm run clean",
22
+ "build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
19
23
  "commitlint": "commitlint --from=master",
20
- "lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different",
21
- "lint:js": "eslint --cache src test",
22
- "lint": "npm-run-all -l -p \"lint:**\"",
23
- "prepare": "npm run build",
24
- "release": "standard-version",
25
24
  "security": "npm audit",
25
+ "lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
26
+ "lint:js": "eslint --cache .",
27
+ "lint": "npm-run-all -l -p \"lint:**\"",
26
28
  "test:only": "cross-env NODE_ENV=test jest",
27
- "test:watch": "cross-env NODE_ENV=test jest --watch",
29
+ "test:watch": "npm run test:only -- --watch",
28
30
  "test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
29
- "test:coverage": "cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage",
31
+ "test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
30
32
  "pretest": "npm run lint",
31
- "test": "cross-env NODE_ENV=test npm run test:coverage",
33
+ "test": "npm run test:coverage",
34
+ "prepare": "npm run build",
35
+ "release": "standard-version",
32
36
  "defaults": "webpack-defaults"
33
37
  },
34
38
  "files": [
35
39
  "dist"
36
40
  ],
37
41
  "peerDependencies": {
38
- "webpack": "^3.0.0 || ^4.0.0"
42
+ "webpack": "^4.36.0 || ^5.0.0",
43
+ "node-sass": "^4.0.0",
44
+ "sass": "^1.3.0",
45
+ "fibers": ">= 3.1.0"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "node-sass": {
49
+ "optional": true
50
+ },
51
+ "sass": {
52
+ "optional": true
53
+ },
54
+ "fibers": {
55
+ "optional": true
56
+ }
39
57
  },
40
58
  "dependencies": {
41
59
  "clone-deep": "^4.0.1",
42
- "loader-utils": "^1.0.1",
43
- "neo-async": "^2.5.0",
44
- "pify": "^4.0.1",
60
+ "loader-utils": "^1.2.3",
61
+ "neo-async": "^2.6.1",
62
+ "schema-utils": "^2.6.1",
45
63
  "semver": "^6.3.0"
46
64
  },
47
65
  "devDependencies": {
48
- "@babel/cli": "^7.5.5",
49
- "@babel/core": "^7.5.5",
50
- "@babel/preset-env": "^7.5.5",
51
- "@commitlint/cli": "^8.1.0",
52
- "@commitlint/config-conventional": "^8.1.0",
53
- "@webpack-contrib/defaults": "^5.0.2",
66
+ "@babel/cli": "^7.8.0",
67
+ "@babel/core": "^7.8.0",
68
+ "@babel/preset-env": "^7.8.2",
69
+ "@commitlint/cli": "^8.3.4",
70
+ "@commitlint/config-conventional": "^8.3.4",
71
+ "@webpack-contrib/defaults": "^6.3.0",
54
72
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
55
73
  "babel-jest": "^24.9.0",
56
- "bootstrap": "^4.3.1",
57
- "bootstrap-sass": "^3.3.5",
58
- "chokidar": "^2.1.6",
59
- "commitlint-azure-pipelines-cli": "^1.0.2",
60
- "cross-env": "^5.2.0",
61
- "css-loader": "^3.2.0",
62
- "del": "^4.1.1",
63
- "del-cli": "^1.1.0",
64
- "eslint": "^6.1.0",
65
- "eslint-config-prettier": "^6.0.0",
66
- "eslint-plugin-import": "^2.14.0",
67
- "file-loader": "^4.2.0",
68
- "husky": "^3.0.3",
74
+ "bootstrap": "^4.4.1",
75
+ "bootstrap-sass": "^3.4.1",
76
+ "commitlint-azure-pipelines-cli": "^1.0.3",
77
+ "cross-env": "^6.0.3",
78
+ "css-loader": "^3.4.2",
79
+ "del": "^5.1.0",
80
+ "del-cli": "^3.0.0",
81
+ "eslint": "^6.8.0",
82
+ "eslint-config-prettier": "^6.9.0",
83
+ "eslint-plugin-import": "^2.20.0",
84
+ "fibers": "^4.0.2",
85
+ "file-loader": "^5.0.2",
86
+ "husky": "^4.0.7",
69
87
  "jest": "^24.9.0",
70
- "jest-junit": "^7.0.0",
88
+ "jest-junit": "^10.0.0",
71
89
  "jquery": "^3.4.1",
72
- "lint-staged": "^9.2.1",
73
- "memory-fs": "^0.4.1",
74
- "node-sass": "^4.5.0",
90
+ "lint-staged": "^9.5.0",
91
+ "memfs": "^3.0.3",
92
+ "node-sass": "^4.13.0",
75
93
  "npm-run-all": "^4.1.5",
76
- "nyc": "^14.1.1",
77
- "popper.js": "^1.15.0",
78
- "prettier": "^1.15.2",
79
- "raw-loader": "^3.1.0",
80
- "sass": "^1.3.0",
81
- "standard-version": "^7.0.0",
82
- "style-loader": "^1.0.0",
83
- "webpack": "^4.5.0",
84
- "webpack-cli": "^3.1.0",
85
- "webpack-dev-server": "^3.1.4"
94
+ "prettier": "^1.19.1",
95
+ "sass": "^1.24.4",
96
+ "standard-version": "^7.0.1",
97
+ "style-loader": "^1.1.2",
98
+ "webpack": "^4.41.5",
99
+ "webpack-cli": "^3.3.10",
100
+ "webpack-dev-server": "^3.10.1"
86
101
  },
87
102
  "keywords": [
88
103
  "sass",
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _os = _interopRequireDefault(require("os"));
11
-
12
- var _fs = _interopRequireDefault(require("fs"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- // A typical sass error looks like this
17
- // const SassError = {
18
- // message: "invalid property name",
19
- // column: 14,
20
- // line: 1,
21
- // file: "stdin",
22
- // status: 1
23
- // };
24
-
25
- /**
26
- * Enhances the sass error with additional information about what actually went wrong.
27
- *
28
- * @param {SassError} error
29
- * @param {string} resourcePath
30
- */
31
- function formatSassError(error, resourcePath) {
32
- // Instruct webpack to hide the JS stack from the console
33
- // Usually you're only interested in the SASS stack in this case.
34
- // eslint-disable-next-line no-param-reassign
35
- error.hideStack = true; // The file property is missing in rare cases.
36
- // No improvement in the error is possible.
37
-
38
- if (!error.file) {
39
- return;
40
- }
41
-
42
- let msg = error.message;
43
-
44
- if (error.file === 'stdin') {
45
- // eslint-disable-next-line no-param-reassign
46
- error.file = resourcePath;
47
- } // node-sass returns UNIX-style paths
48
- // eslint-disable-next-line no-param-reassign
49
-
50
-
51
- error.file = _path.default.normalize(error.file); // The 'Current dir' hint of node-sass does not help us, we're providing
52
- // additional information by reading the err.file property
53
-
54
- msg = msg.replace(/\s*Current dir:\s*/, ''); // msg = msg.replace(/(\s*)(stdin)(\s*)/, `$1${err.file}$3`);
55
- // eslint-disable-next-line no-param-reassign
56
-
57
- error.message = `${getFileExcerptIfPossible(error) + msg.charAt(0).toUpperCase() + msg.slice(1) + _os.default.EOL} in ${error.file} (line ${error.line}, column ${error.column})`;
58
- }
59
- /**
60
- * Tries to get an excerpt of the file where the error happened.
61
- * Uses err.line and err.column.
62
- *
63
- * Returns an empty string if the excerpt could not be retrieved.
64
- *
65
- * @param {SassError} error
66
- * @returns {string}
67
- */
68
-
69
-
70
- function getFileExcerptIfPossible(error) {
71
- try {
72
- const content = _fs.default.readFileSync(error.file, 'utf8');
73
-
74
- return `${_os.default.EOL + content.split(/\r?\n/)[error.line - 1] + _os.default.EOL + new Array(error.column - 1).join(' ')}^${_os.default.EOL} `;
75
- } catch (ignoreError) {
76
- // If anything goes wrong here, we don't want any errors to be reported to the user
77
- return '';
78
- }
79
- }
80
-
81
- var _default = formatSassError;
82
- exports.default = _default;