@@ -114,23 +114,41 @@ module.exports = {
114114
115115## Options
116116
117- | Name | Type | Default | Description |
118- | :-----------------------------------------: | :-----------------: | :-------------: | :------------------------------------------ |
119- | ** [ ` url ` ] ( #url ) ** | ` {Boolean} ` | ` true ` | Enable/Disable ` url() ` handling |
120- | ** [ ` import ` ] ( #import ) ** | ` {Boolean} ` | ` true ` | Enable/Disable @import handling |
121- | ** [ ` modules ` ] ( #modules ) ** | ` {Boolean\|String} ` | ` false ` | Enable/Disable CSS Modules and setup mode |
122- | ** [ ` localIdentName ` ] ( #localidentname ) ** | ` {String} ` | ` [hash:base64] ` | Configure the generated ident |
123- | ** [ ` sourceMap ` ] ( #sourcemap ) ** | ` {Boolean} ` | ` false ` | Enable/Disable Sourcemaps |
124- | ** [ ` camelCase ` ] ( #camelcase ) ** | ` {Boolean\|String} ` | ` false ` | Export Classnames in CamelCase |
125- | ** [ ` importLoaders ` ] ( #importloaders ) ** | ` {Number} ` | ` 0 ` | Number of loaders applied before CSS loader |
126- | ** [ ` exportOnlyLocals ` ] ( #exportonlylocals ) ** | ` {Boolean} ` | ` false ` | Export only locals |
117+ | Name | Type | Default | Description |
118+ | :-----------------------------------------: | :------------------- : | :-------------: | :------------------------------------------ |
119+ | ** [ ` url ` ] ( #url ) ** | ` {Boolean\|Function} ` | ` true ` | Enable/Disable ` url() ` handling |
120+ | ** [ ` import ` ] ( #import ) ** | ` {Boolean} ` | ` true ` | Enable/Disable @import handling |
121+ | ** [ ` modules ` ] ( #modules ) ** | ` {Boolean\|String} ` | ` false ` | Enable/Disable CSS Modules and setup mode |
122+ | ** [ ` localIdentName ` ] ( #localidentname ) ** | ` {String} ` | ` [hash:base64] ` | Configure the generated ident |
123+ | ** [ ` sourceMap ` ] ( #sourcemap ) ** | ` {Boolean} ` | ` false ` | Enable/Disable Sourcemaps |
124+ | ** [ ` camelCase ` ] ( #camelcase ) ** | ` {Boolean\|String} ` | ` false ` | Export Classnames in CamelCase |
125+ | ** [ ` importLoaders ` ] ( #importloaders ) ** | ` {Number} ` | ` 0 ` | Number of loaders applied before CSS loader |
126+ | ** [ ` exportOnlyLocals ` ] ( #exportonlylocals ) ** | ` {Boolean} ` | ` false ` | Export only locals |
127127
128128### ` url `
129129
130- Type: ` Boolean `
130+ Type: ` Boolean|Function `
131131Default: ` true `
132132
133- Enable/disable ` url() ` resolving. Absolute ` urls ` are not resolving by default.
133+ Control ` url() ` resolving. Absolute ` urls ` are not resolving by default.
134+
135+ Examples resolutions:
136+
137+ ```
138+ url(image.png) => require('./image.png')
139+ url(./image.png) => require('./image.png')
140+ ```
141+
142+ To import assets from a ` node_modules ` path (include ` resolve.modules ` ) and for ` alias ` , prefix it with a ` ~ ` :
143+
144+ ```
145+ url(~module/image.png) => require('module/image.png')
146+ url(~aliasDirectory/image.png) => require('otherDirectory/image.png')
147+ ```
148+
149+ #### ` Boolean `
150+
151+ Enable/disable ` url() ` resolving.
134152
135153** webpack.config.js**
136154
@@ -150,18 +168,27 @@ module.exports = {
150168};
151169```
152170
153- Examples resolutions:
171+ #### ` Function `
154172
155- ```
156- url(image.png) => require('./image.png')
157- url(./image.png) => require('./image.png')
158- ```
159-
160- To import assets from a ` node_modules ` path (include ` resolve.modules ` ) and for ` alias ` , prefix it with a ` ~ ` :
173+ Allow to filter ` url() ` . All filtered ` url() ` will not be resolved.
161174
162- ```
163- url(~module/image.png) => require('module/image.png')
164- url(~aliasDirectory/image.png) => require('otherDirectory/image.png')
175+ ``` js
176+ module .exports = {
177+ module: {
178+ rules: [
179+ {
180+ test: / \. css$ / ,
181+ loader: ' css-loader' ,
182+ options: {
183+ url : (url , resourcePath ) => {
184+ // `url()` with `img.png` stay untouched
185+ return url .includes (' img.png' );
186+ },
187+ },
188+ },
189+ ],
190+ },
191+ };
165192```
166193
167194### ` import `
0 commit comments