Skip to content

Commit ae9b834

Browse files
feat(import): add @import filter support (options.import)
1 parent f9c60da commit ae9b834

File tree

17 files changed

+138
-329
lines changed

17 files changed

+138
-329
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,32 @@ To disable `@import` resolving by `css-loader` set the option to `false`
146146
}
147147
```
148148

149+
#### `{RegExp}`
150+
151+
**webpack.config.js**
152+
```js
153+
{
154+
loader: 'css-loader',
155+
options: {
156+
import: /filter/
157+
}
158+
}
159+
```
160+
161+
#### `{Function}`
162+
163+
**webpack.config.js**
164+
```js
165+
{
166+
loader: 'css-loader',
167+
options: {
168+
import (url) {
169+
return /filter/.test(url)
170+
}
171+
}
172+
}
173+
```
174+
149175
### `minimize`
150176

151177
#### `{Boolean}`

src/index.js

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

5454
// Import Plugin
5555
if (options.import) {
56-
plugins.push(imports());
56+
plugins.push(imports(options));
5757
}
5858

5959
// Minifier

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
@@ -10,7 +10,12 @@
1010
]
1111
},
1212
"import": {
13-
"type": "boolean"
13+
"anyOf": [
14+
{ "type": "string" },
15+
{ "type": "boolean" },
16+
{ "instanceof": "RegExp" },
17+
{ "instanceof": "Function" }
18+
]
1419
},
1520
"minimize": {
1621
"type": "boolean"

0 commit comments

Comments
 (0)