sass-loader 4.0.0 → 4.1.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/.jshintignore +0 -0
- package/.jshintrc +0 -0
- package/.npmignore +19 -19
- package/.travis.yml +6 -0
- package/CHANGELOG.md +17 -1
- package/README.md +14 -14
- package/index.js +33 -4
- package/package.json +9 -9
package/.jshintignore
CHANGED
|
File without changes
|
package/.jshintrc
CHANGED
|
File without changes
|
package/.npmignore
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
lib-cov
|
|
2
|
-
*.seed
|
|
3
|
-
*.log
|
|
4
|
-
*.csv
|
|
5
|
-
*.dat
|
|
6
|
-
*.out
|
|
7
|
-
*.pid
|
|
8
|
-
*.gz
|
|
9
|
-
|
|
10
|
-
pids
|
|
11
|
-
logs
|
|
12
|
-
results
|
|
13
|
-
|
|
14
|
-
npm-debug.log
|
|
15
|
-
node_modules
|
|
16
|
-
coverage
|
|
17
|
-
examples
|
|
18
|
-
test
|
|
19
|
-
.idea
|
|
1
|
+
lib-cov
|
|
2
|
+
*.seed
|
|
3
|
+
*.log
|
|
4
|
+
*.csv
|
|
5
|
+
*.dat
|
|
6
|
+
*.out
|
|
7
|
+
*.pid
|
|
8
|
+
*.gz
|
|
9
|
+
|
|
10
|
+
pids
|
|
11
|
+
logs
|
|
12
|
+
results
|
|
13
|
+
|
|
14
|
+
npm-debug.log
|
|
15
|
+
node_modules
|
|
16
|
+
coverage
|
|
17
|
+
examples
|
|
18
|
+
test
|
|
19
|
+
.idea
|
package/.travis.yml
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
---------
|
|
3
3
|
|
|
4
|
+
### 4.1.0
|
|
5
|
+
|
|
6
|
+
- Update `node-sass@4.0.0` [#319](https://github.com/jtangelder/sass-loader/pull/319)
|
|
7
|
+
|
|
8
|
+
### 4.0.2
|
|
9
|
+
|
|
10
|
+
- Fix wrong context in customImporters that was introduced with fd6be1f143a1810f7e5072a865b3d8675ba1b94e [#275](https://github.com/jtangelder/sass-loader/issues/275) [#277](https://github.com/jtangelder/sass-loader/pull/277)
|
|
11
|
+
|
|
12
|
+
### 4.0.1
|
|
13
|
+
|
|
14
|
+
- Fix custom importers receiving `'stdin'` as second argument instead of the actual `resourcePath` [#267](https://github.com/jtangelder/sass-loader/pull/267)
|
|
15
|
+
|
|
4
16
|
### 4.0.0
|
|
5
17
|
|
|
6
|
-
- **Breaking**: Release new major version because
|
|
18
|
+
- **Breaking**: Release new major version because `3.2.2` was a breaking change in certain scenarios [#250](https://github.com/jtangelder/sass-loader/pull/250) [#254](https://github.com/jtangelder/sass-loader/issues/254)
|
|
19
|
+
|
|
20
|
+
### 3.2.3
|
|
21
|
+
|
|
22
|
+
- Revert changes to `3.2.1` because `3.2.2` contained a potential breaking change [#254](https://github.com/jtangelder/sass-loader/issues/254)
|
|
7
23
|
|
|
8
24
|
### 3.2.2
|
|
9
25
|
|
package/README.md
CHANGED
|
@@ -14,22 +14,22 @@ as [`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies
|
|
|
14
14
|
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
|
|
15
15
|
|
|
16
16
|
``` javascript
|
|
17
|
-
var css = require("!raw!sass!./file.scss");
|
|
17
|
+
var css = require("!raw-loader!sass-loader!./file.scss");
|
|
18
18
|
// returns compiled css code from file.scss, resolves Sass imports
|
|
19
|
-
var css = require("!css!sass!./file.scss");
|
|
19
|
+
var css = require("!css-loader!sass-loader!./file.scss");
|
|
20
20
|
// returns compiled css code from file.scss, resolves Sass and CSS imports and url(...)s
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Use in tandem with the [`style-loader`](https://github.com/webpack/style-loader) and [`css-loader`](https://github.com/webpack/css-loader) to add the css rules to your document:
|
|
24
24
|
|
|
25
25
|
``` javascript
|
|
26
|
-
require("!style!css!sass!./file.scss");
|
|
26
|
+
require("!style-loader!css-loader!sass-loader!./file.scss");
|
|
27
27
|
```
|
|
28
28
|
*Please note: If you encounter module errors complaining about a missing `style` or `css` module, make sure you have installed all required loaders via npm.*
|
|
29
29
|
|
|
30
30
|
### Apply via webpack config
|
|
31
31
|
|
|
32
|
-
It's recommended to adjust your `webpack.config` so `style!css!sass!` is applied automatically on all files ending on `.scss`:
|
|
32
|
+
It's recommended to adjust your `webpack.config` so `style-loader!css-loader!sass-loader!` is applied automatically on all files ending on `.scss`:
|
|
33
33
|
|
|
34
34
|
``` javascript
|
|
35
35
|
module.exports = {
|
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
|
38
38
|
loaders: [
|
|
39
39
|
{
|
|
40
40
|
test: /\.scss$/,
|
|
41
|
-
loaders: ["style", "css", "sass"]
|
|
41
|
+
loaders: ["style-loader", "css-loader", "sass-loader"]
|
|
42
42
|
}
|
|
43
43
|
]
|
|
44
44
|
}
|
|
@@ -49,7 +49,7 @@ Then you only need to write: `require("./file.scss")`.
|
|
|
49
49
|
|
|
50
50
|
### Sass options
|
|
51
51
|
|
|
52
|
-
You can pass options to node-sass by defining a `sassLoader
|
|
52
|
+
You can pass options to node-sass by defining a `sassLoader` property on your `webpack.config.js`. See [node-sass](https://github.com/andrew/node-sass) for all available Sass options.
|
|
53
53
|
|
|
54
54
|
```javascript
|
|
55
55
|
module.exports = {
|
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
|
58
58
|
loaders: [
|
|
59
59
|
{
|
|
60
60
|
test: /\.scss$/,
|
|
61
|
-
loaders: ["style", "css", "sass"]
|
|
61
|
+
loaders: ["style-loader", "css-loader", "sass-loader"]
|
|
62
62
|
}
|
|
63
63
|
]
|
|
64
64
|
},
|
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
|
70
70
|
|
|
71
71
|
Passing your options as [query parameters](http://webpack.github.io/docs/using-loaders.html#query-parameters) is also supported, but can get confusing if you need to set a lot of options.
|
|
72
72
|
|
|
73
|
-
If you need to define two different loader configs, you can also change the config's property name via `sass?config=otherSassLoaderConfig`:
|
|
73
|
+
If you need to define two different loader configs, you can also change the config's property name via `sass-loader?config=otherSassLoaderConfig`:
|
|
74
74
|
|
|
75
75
|
```javascript
|
|
76
76
|
module.exports = {
|
|
@@ -79,7 +79,7 @@ module.exports = {
|
|
|
79
79
|
loaders: [
|
|
80
80
|
{
|
|
81
81
|
test: /\.scss$/,
|
|
82
|
-
loaders: ["style", "css", "sass?config=otherSassLoaderConfig"]
|
|
82
|
+
loaders: ["style-loader", "css-loader", "sass-loader?config=otherSassLoaderConfig"]
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
85
|
},
|
|
@@ -102,11 +102,11 @@ Alternatively, for bootstrap-sass:
|
|
|
102
102
|
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
It's important to only prepend it with `~`, because `~/` resolves to the home directory. webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS
|
|
105
|
+
It's important to only prepend it with `~`, because `~/` resolves to the home directory. webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files. Writing `@import "file"` is the same as `@import "./file";`
|
|
106
106
|
|
|
107
107
|
### Environment variables
|
|
108
108
|
|
|
109
|
-
If you want to prepend Sass code before the actual entry file, you can simply set the `data
|
|
109
|
+
If you want to prepend Sass code before the actual entry file, you can simply set the `data` option. In this case, the sass-loader will not override the `data` option but just append the entry's content. This is especially useful when some of your Sass variables depend on the environment:
|
|
110
110
|
|
|
111
111
|
```javascript
|
|
112
112
|
module.exports = {
|
|
@@ -125,7 +125,7 @@ Since Sass/[libsass](https://github.com/sass/libsass) does not provide [url rewr
|
|
|
125
125
|
- If you're just generating CSS without passing it to the css-loader, it must be relative to your web root.
|
|
126
126
|
- If you pass the generated CSS on to the css-loader, all urls must be relative to the entry-file (e.g. `main.scss`).
|
|
127
127
|
|
|
128
|
-
More likely you will be disrupted by this second issue. It is natural to expect relative references to be resolved against the `.scss
|
|
128
|
+
More likely you will be disrupted by this second issue. It is natural to expect relative references to be resolved against the `.scss` file in which they are specified (like in regular `.css` files). Thankfully there are a two solutions to this problem:
|
|
129
129
|
|
|
130
130
|
- Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it directly after the sass-loader in the loader chain.
|
|
131
131
|
- 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/jtangelder/sass-loader/tree/master/test/bootstrapSass).
|
|
@@ -141,7 +141,7 @@ There are two possibilties to extract a stylesheet from the bundle:
|
|
|
141
141
|
|
|
142
142
|
### Source maps
|
|
143
143
|
|
|
144
|
-
To enable CSS Source maps, you'll need to pass the `sourceMap
|
|
144
|
+
To enable CSS Source maps, you'll need to pass the `sourceMap` option to the sass *and* the css-loader. Your `webpack.config.js` should look like this:
|
|
145
145
|
|
|
146
146
|
```javascript
|
|
147
147
|
module.exports = {
|
|
@@ -151,7 +151,7 @@ module.exports = {
|
|
|
151
151
|
loaders: [
|
|
152
152
|
{
|
|
153
153
|
test: /\.scss$/,
|
|
154
|
-
loaders: ["style", "css?sourceMap", "sass?sourceMap"]
|
|
154
|
+
loaders: ["style-loader", "css-loader?sourceMap", "sass-loader?sourceMap"]
|
|
155
155
|
}
|
|
156
156
|
]
|
|
157
157
|
}
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var SassError = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
// libsass uses this precedence when importing files without extension
|
|
21
|
+
var slice = Array.prototype.slice;
|
|
21
22
|
var extPrecedence = ['.scss', '.sass', '.css'];
|
|
22
23
|
var matchCss = /\.css$/;
|
|
23
24
|
|
|
@@ -223,7 +224,7 @@ module.exports = function (content) {
|
|
|
223
224
|
if (sassOptions.sourceMap) {
|
|
224
225
|
// deliberately overriding the sourceMap option
|
|
225
226
|
// this value is (currently) ignored by libsass when using the data input instead of file input
|
|
226
|
-
// however, it is still necessary for correct relative paths in result.map.sources
|
|
227
|
+
// however, it is still necessary for correct relative paths in result.map.sources.
|
|
227
228
|
sassOptions.sourceMap = this.options.context + '/sass.map';
|
|
228
229
|
sassOptions.omitSourceMapUrl = true;
|
|
229
230
|
|
|
@@ -234,10 +235,10 @@ module.exports = function (content) {
|
|
|
234
235
|
}
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
// indentedSyntax is a boolean flag
|
|
238
|
+
// indentedSyntax is a boolean flag.
|
|
238
239
|
var ext = path.extname(resourcePath);
|
|
239
240
|
|
|
240
|
-
// If we are
|
|
241
|
+
// If we are compiling sass and indentedSyntax isn't set, automatically set it.
|
|
241
242
|
if (ext && ext.toLowerCase() === '.sass' && sassOptions.indentedSyntax === undefined) {
|
|
242
243
|
sassOptions.indentedSyntax = true;
|
|
243
244
|
} else {
|
|
@@ -245,7 +246,7 @@ module.exports = function (content) {
|
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
// Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s.
|
|
248
|
-
sassOptions.importer = sassOptions.importer ?
|
|
249
|
+
sassOptions.importer = sassOptions.importer ? proxyCustomImporters(sassOptions.importer, resourcePath) : [];
|
|
249
250
|
sassOptions.importer.push(getWebpackImporter());
|
|
250
251
|
|
|
251
252
|
// `node-sass` uses `includePaths` to resolve `@import` paths. Append the currently processed file.
|
|
@@ -391,3 +392,31 @@ function getLoaderConfig(loaderContext) {
|
|
|
391
392
|
|
|
392
393
|
return assign({}, config, query);
|
|
393
394
|
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Creates new custom importers that use the given `resourcePath` if libsass calls the custom importer with `prev`
|
|
398
|
+
* being 'stdin'.
|
|
399
|
+
*
|
|
400
|
+
* Why do we need this?
|
|
401
|
+
*
|
|
402
|
+
* We have to use the `data` option of node-sass in order to compile our sass because the `resourcePath` might
|
|
403
|
+
* not be an actual file on disk. When using the `data` option, libsass uses the string 'stdin' instead of a
|
|
404
|
+
* filename. We have to fix this behavior in order to provide a consistent experience to the webpack user.
|
|
405
|
+
*
|
|
406
|
+
* @param {function|Array<function>} importer
|
|
407
|
+
* @param {string} resourcePath
|
|
408
|
+
* @returns {Array<function>}
|
|
409
|
+
*/
|
|
410
|
+
function proxyCustomImporters(importer, resourcePath) {
|
|
411
|
+
return [].concat(importer).map(function (importer) {
|
|
412
|
+
return function (url, prev, done) {
|
|
413
|
+
var args = slice.call(arguments);
|
|
414
|
+
|
|
415
|
+
if (args[1] === 'stdin') {
|
|
416
|
+
args[1] = resourcePath;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return importer.apply(this, args);
|
|
420
|
+
};
|
|
421
|
+
});
|
|
422
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Sass loader for webpack",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"author": "J. Tangelder",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"node-sass": "^3.4.2",
|
|
31
|
-
"webpack": "^
|
|
30
|
+
"node-sass": "^3.4.2 || ^4.0.0",
|
|
31
|
+
"webpack": "^2 || ^2.2.0-rc.0 || ^2.1.0-beta || ^1.12.6"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"async": "^
|
|
34
|
+
"async": "^2.0.1",
|
|
35
35
|
"loader-utils": "^0.2.15",
|
|
36
36
|
"object-assign": "^4.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"bootstrap-sass": "^3.3.5",
|
|
40
|
-
"css-loader": "^0.
|
|
40
|
+
"css-loader": "^0.24.0",
|
|
41
41
|
"enhanced-require": "^0.5.0-beta6",
|
|
42
|
-
"file-loader": "^0.
|
|
42
|
+
"file-loader": "^0.9.0",
|
|
43
43
|
"jshint": "^2.9.2",
|
|
44
|
-
"mocha": "^
|
|
45
|
-
"node-sass": "^
|
|
44
|
+
"mocha": "^3.0.2",
|
|
45
|
+
"node-sass": "^4.0.0",
|
|
46
46
|
"raw-loader": "^0.5.1",
|
|
47
|
-
"should": "^
|
|
47
|
+
"should": "^11.1.0",
|
|
48
48
|
"style-loader": "^0.13.1",
|
|
49
49
|
"webpack": "^1.13.1",
|
|
50
50
|
"webpack-dev-server": "^1.7.0"
|