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
Copy file name to clipboardExpand all lines: README.md
+34-22Lines changed: 34 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
-
[![npm-version][npm-version]][npm-url]
1
+
[![npm][npm]][npm-url]
2
+
[![node][node]][node-url]
2
3
[![npm-stats][npm-stats]][npm-url]
3
4
[![deps][deps]][deps-url]
4
5
[![travis][travis]][travis-url]
5
-
[![coverage][coverage]][coverage-url]
6
+
[![appveyor][appveyor]][appveyor-url]
7
+
[![coverage][cover]][cover-url]
8
+
[![chat][chat]][chat-url]
6
9
7
10
<divalign="center">
8
11
<img height="100"
@@ -120,20 +123,6 @@ webpack provides an [advanced mechanism to resolve files](http://webpack.github.
120
123
121
124
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";`
122
125
123
-
### Environment variables
124
-
125
-
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:
126
-
127
-
```javascript
128
-
{
129
-
loader:"sass-loader",
130
-
options: {
131
-
data:"$env: "+process.env.NODE_ENV+";"
132
-
}
133
-
}
134
-
```
135
-
136
-
137
126
### Problems with `url(...)`
138
127
139
128
Since Sass/[libsass](https://github.com/sass/libsass) does not provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.
@@ -146,11 +135,11 @@ More likely you will be disrupted by this second issue. It is natural to expect
146
135
- 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.
147
136
- 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).
148
137
149
-
### Extracting stylesheets
138
+
### Extracting style sheets
150
139
151
-
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.
140
+
Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed urls or [hot module replacement](https://webpack.js.org/concepts/hot-module-replacement/) in development. In production, on the other hand, it's not a good idea to apply your style sheets 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.
152
141
153
-
There are two possibilties to extract a stylesheet from the bundle:
142
+
There are two possibilities to extract a style sheet from the bundle:
154
143
155
144
-[extract-loader](https://github.com/peerigon/extract-loader) (simpler, but specialized on the css-loader's output)
156
145
-[extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) (more complex, but works in all use-cases)
@@ -184,6 +173,20 @@ module.exports = {
184
173
185
174
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.
186
175
176
+
### Environment variables
177
+
178
+
If you want to prepend Sass code before the actual entry file, you can 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:
179
+
180
+
```javascript
181
+
{
182
+
loader:"sass-loader",
183
+
options: {
184
+
data:"$env: "+process.env.NODE_ENV+";"
185
+
}
186
+
}
187
+
```
188
+
189
+
***Please note:** 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.**
187
190
188
191
## Maintainers
189
192
@@ -214,15 +217,24 @@ If you want to edit the original Sass files inside Chrome, [there's a good blog
0 commit comments