sass-loader 3.1.2 → 3.2.3
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 +11 -2
- package/README.md +32 -9
- package/index.js +10 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
---------
|
|
3
3
|
|
|
4
|
+
### 3.2.1
|
|
5
|
+
|
|
6
|
+
- Add `webpack@^2.1.0-beta` as peer dependency [#233](https://github.com/jtangelder/sass-loader/pull/233)
|
|
7
|
+
|
|
8
|
+
### 3.2.0
|
|
9
|
+
|
|
10
|
+
- Append file content instead of overwriting when `data`-option is already present [#216](https://github.com/jtangelder/sass-loader/pull/216)
|
|
11
|
+
- Make `indentedSyntax` option a bit smarter [#196](https://github.com/jtangelder/sass-loader/pull/196)
|
|
12
|
+
|
|
4
13
|
### 3.1.2
|
|
5
14
|
|
|
6
15
|
- Fix loader query not overriding webpack config [#189](https://github.com/jtangelder/sass-loader/pull/189)
|
|
7
16
|
- Update peer-dependencies [#182](https://github.com/jtangelder/sass-loader/pull/182)
|
|
8
|
-
- `node-sass
|
|
9
|
-
- `webpack
|
|
17
|
+
- `node-sass@^3.4.2`
|
|
18
|
+
- `webpack@^1.12.6`
|
|
10
19
|
|
|
11
20
|
### 3.1.1
|
|
12
21
|
|
package/README.md
CHANGED
|
@@ -15,9 +15,9 @@ as [`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies
|
|
|
15
15
|
|
|
16
16
|
``` javascript
|
|
17
17
|
var css = require("!raw!sass!./file.scss");
|
|
18
|
-
//
|
|
18
|
+
// returns compiled css code from file.scss, resolves Sass imports
|
|
19
19
|
var css = require("!css!sass!./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:
|
|
@@ -25,7 +25,7 @@ Use in tandem with the [`style-loader`](https://github.com/webpack/style-loader)
|
|
|
25
25
|
``` javascript
|
|
26
26
|
require("!style!css!sass!./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
|
|
|
@@ -49,9 +49,9 @@ 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`-property on your `webpack.config.js`. See [node-sass](https://github.com/andrew/node-sass) for all available options.
|
|
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 = {
|
|
56
56
|
...
|
|
57
57
|
module: {
|
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
|
61
61
|
loaders: ["style", "css", "sass"]
|
|
62
62
|
}
|
|
63
63
|
]
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
65
|
sassLoader: {
|
|
66
66
|
includePaths: [path.resolve(__dirname, "./some-folder")]
|
|
67
67
|
}
|
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
|
82
82
|
loaders: ["style", "css", "sass?config=otherSassLoaderConfig"]
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
otherSassLoaderConfig: {
|
|
87
87
|
...
|
|
88
88
|
}
|
|
@@ -91,13 +91,27 @@ module.exports = {
|
|
|
91
91
|
|
|
92
92
|
### Imports
|
|
93
93
|
|
|
94
|
-
webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The sass-loader uses node-sass' custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your
|
|
94
|
+
webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The sass-loader uses node-sass' 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:
|
|
95
95
|
|
|
96
96
|
```css
|
|
97
97
|
@import "~bootstrap/less/bootstrap";
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
It's important to only prepend it with `~`, because `~/` resolves to the home
|
|
100
|
+
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";`
|
|
101
|
+
|
|
102
|
+
### Environment variables
|
|
103
|
+
|
|
104
|
+
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:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
module.exports = {
|
|
108
|
+
...
|
|
109
|
+
sassLoader: {
|
|
110
|
+
data: "$env: " + process.env.NODE_ENV + ";"
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
```
|
|
114
|
+
|
|
101
115
|
|
|
102
116
|
### Problems with `url(...)`
|
|
103
117
|
|
|
@@ -111,6 +125,15 @@ More likely you will be disrupted by this second issue. It is natural to expect
|
|
|
111
125
|
- 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.
|
|
112
126
|
- 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).
|
|
113
127
|
|
|
128
|
+
### Extracting stylesheets
|
|
129
|
+
|
|
130
|
+
Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed urls or [hot module replacement](http://webpack.github.io/docs/hot-module-replacement-with-webpack.html) in development. In production, on the other hand, it's not a good idea to apply your stylesheets depending on JS execution. Rendering may be delayed or even a [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) might be visible. Thus it's often still better to have them as separate files in your final production build.
|
|
131
|
+
|
|
132
|
+
There are two possibilties to extract a stylesheet from the bundle:
|
|
133
|
+
|
|
134
|
+
- [extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
|
|
135
|
+
- [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin) (more complex, but works in all use-cases)
|
|
136
|
+
|
|
114
137
|
### Source maps
|
|
115
138
|
|
|
116
139
|
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:
|
package/index.js
CHANGED
|
@@ -205,10 +205,10 @@ module.exports = function (content) {
|
|
|
205
205
|
|
|
206
206
|
this.cacheable();
|
|
207
207
|
|
|
208
|
-
sassOptions.data = content;
|
|
208
|
+
sassOptions.data = sassOptions.data ? (sassOptions.data + os.EOL + content) : content;
|
|
209
209
|
|
|
210
210
|
// Skip empty files, otherwise it will stop webpack, see issue #21
|
|
211
|
-
if (
|
|
211
|
+
if (sassOptions.data.trim() === '') {
|
|
212
212
|
return isSync ? content : callback(null, content);
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -235,7 +235,14 @@ module.exports = function (content) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
// indentedSyntax is a boolean flag
|
|
238
|
-
|
|
238
|
+
var ext = path.extname(resourcePath);
|
|
239
|
+
|
|
240
|
+
// If we are compling sass and indentedSyntax isn't set, automatically set it.
|
|
241
|
+
if (ext && ext.toLowerCase() === '.sass' && sassOptions.indentedSyntax === undefined) {
|
|
242
|
+
sassOptions.indentedSyntax = true;
|
|
243
|
+
} else {
|
|
244
|
+
sassOptions.indentedSyntax = Boolean(sassOptions.indentedSyntax);
|
|
245
|
+
}
|
|
239
246
|
|
|
240
247
|
// Allow passing custom importers to `node-sass`. Accepts `Function` or an array of `Function`s.
|
|
241
248
|
sassOptions.importer = sassOptions.importer ? [].concat(sassOptions.importer) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-loader",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Sass loader for webpack",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"node-sass": "^3.4.2",
|
|
31
|
-
"webpack": "^1.12.6"
|
|
31
|
+
"webpack": "^1.12.6 || ^2.1.0-beta"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"async": "^1.4.0",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"mocha": "^2.3.4",
|
|
45
45
|
"node-sass": "3.4.2",
|
|
46
46
|
"raw-loader": "^0.5.1",
|
|
47
|
-
"should": "^
|
|
47
|
+
"should": "^8.2.2",
|
|
48
48
|
"style-loader": "^0.13.0",
|
|
49
|
-
"webpack": "1.12.
|
|
49
|
+
"webpack": "^1.12.14",
|
|
50
50
|
"webpack-dev-server": "^1.7.0"
|
|
51
51
|
}
|
|
52
52
|
}
|