Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 0854c44

Browse files
robertsheacoleevilebottnawi
authored andcommitted
docs(README): add example how-to disable url() resolving (#677)
* Add array of loaders and options I was scouring the internet looking for how to get my css url() to resolve when webpack compiles. I couldn't find anything! But, I took a guess at setting `url: false` in the options for my loader and it worked! It would be beneficial to have this documentation on the readme. Thanks for the awesome plugin! * Update README.md
1 parent cc3ba94 commit 0854c44

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ module.exports = {
146146
test: /\.scss$/,
147147
use: ExtractTextPlugin.extract({
148148
fallback: 'style-loader',
149-
//resolve-url-loader may be chained before sass-loader if necessary
150149
use: ['css-loader', 'sass-loader']
151150
})
152151
}
@@ -162,6 +161,45 @@ module.exports = {
162161
}
163162
```
164163

164+
### `url()` Resolving
165+
166+
If you are finding that urls are not resolving properly when you run webpack. You can expand your loader functionality with options. The `url: false` property allows your paths resolved without any changes.
167+
168+
```js
169+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
170+
171+
module.exports = {
172+
module: {
173+
rules: [
174+
{
175+
test: /\.scss$/,
176+
use: ExtractTextPlugin.extract({
177+
fallback: 'style-loader',
178+
use: [
179+
{
180+
loader: 'css-loader',
181+
options: {
182+
// If you are having trouble with urls not resolving add this setting.
183+
// See https://github.com/webpack-contrib/css-loader#url
184+
url: false,
185+
minimize: true,
186+
sourceMap: true
187+
}
188+
},
189+
{
190+
loader: 'sass-loader',
191+
options: {
192+
sourceMap: true
193+
}
194+
}
195+
]
196+
})
197+
}
198+
]
199+
}
200+
}
201+
```
202+
165203
### Modify filename
166204

167205
`filename` parameter could be `Function`. It passes `getPath` to process the format like `css/[name].css` and returns the real file name, `css/js/a.css`. You can replace `css/js` with `css` then you will get the new path `css/a.css`.

0 commit comments

Comments
 (0)