Skip to content

Commit af4bc75

Browse files
feat(url): add url() filter support (options.url)
1 parent d9f6bba commit af4bc75

File tree

12 files changed

+150
-336
lines changed

12 files changed

+150
-336
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default `
7474
}
7575
`
7676
```
77+
7778
#### `{Boolean}`
7879

7980
To disable `url()` resolving by `css-loader` set the option to `false`
@@ -88,6 +89,32 @@ To disable `url()` resolving by `css-loader` set the option to `false`
8889
}
8990
```
9091

92+
#### `{RegExp}`
93+
94+
**webpack.config.js**
95+
```js
96+
{
97+
loader: 'css-loader',
98+
options: {
99+
url: /filter/
100+
}
101+
}
102+
```
103+
104+
#### `{Function}`
105+
106+
**webpack.config.js**
107+
```js
108+
{
109+
loader: 'css-loader',
110+
options: {
111+
url (url) {
112+
return /filter/.test(url)
113+
}
114+
}
115+
}
116+
```
117+
91118
### `import`
92119

93120
```css

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function loader (css, map, meta) {
5252

5353
// URL Plugin
5454
if (options.url) {
55-
plugins.push(urls());
55+
plugins.push(urls(options));
5656
}
5757

5858

src/lib/Error.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/lib/plugins/import.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/lib/plugins/url.js

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/lib/runtime.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/options.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
"type": "object",
33
"properties": {
44
"url": {
5-
"type": "boolean"
5+
"anyOf": [
6+
{ "type": "string" },
7+
{ "type": "boolean" },
8+
{ "instanceof": "RegExp" },
9+
{ "instanceof": "Function" }
10+
]
611
},
712
"import": {
813
"type": "boolean"

0 commit comments

Comments
 (0)