css-loader 0.28.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +29 -139
- package/lib/getLocalIdent.js +9 -2
- package/lib/loader.js +5 -11
- package/lib/localsLoader.js +2 -7
- package/lib/processCss.js +7 -25
- package/lib/url/escape.js +3 -0
- package/package.json +7 -6
- package/lib/createResolver.js +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="1.0.0"></a>
|
|
6
|
+
# [1.0.0](https://github.com/webpack-contrib/css-loader/compare/v0.28.11...v1.0.0) (2018-07-06)
|
|
7
|
+
|
|
8
|
+
### BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* remove `minimize` option, use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`cssnano`](https://github.com/cssnano/cssnano) or use [`optimize-cssnano-plugin`](https://github.com/intervolga/optimize-cssnano-plugin) plugin
|
|
11
|
+
* remove `module` option, use `modules` option instead
|
|
12
|
+
* remove `camelcase` option, use `camelCase` option instead
|
|
13
|
+
* remove `root` option, use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`postcss-url`](https://github.com/postcss/postcss-url) plugin
|
|
14
|
+
* remove `alias` option, use [`resolve.alias`](https://webpack.js.org/configuration/resolve/) feature or use [`postcss-loader`](https://github.com/postcss/postcss-loader) with [`postcss-url`](https://github.com/postcss/postcss-url) plugin
|
|
15
|
+
* update `postcss` to `6` version
|
|
16
|
+
* minimum require `nodejs` version is `6.9`
|
|
17
|
+
* minimum require `webpack` version is `4`
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<a name="0.28.11"></a>
|
|
21
|
+
## [0.28.11](https://github.com/webpack-contrib/css-loader/compare/v0.28.10...v0.28.11) (2018-03-16)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **lib/processCss:** don't check `mode` for `url` handling (`options.modules`) ([#698](https://github.com/webpack-contrib/css-loader/issues/698)) ([c788450](https://github.com/webpack-contrib/css-loader/commit/c788450))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<a name="0.28.10"></a>
|
|
31
|
+
## [0.28.10](https://github.com/webpack-contrib/css-loader/compare/v0.28.9...v0.28.10) (2018-02-22)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **getLocalIdent:** add `rootContext` support (`webpack >= v4.0.0`) ([#681](https://github.com/webpack-contrib/css-loader/issues/681)) ([9f876d2](https://github.com/webpack-contrib/css-loader/commit/9f876d2))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<a name="0.28.9"></a>
|
|
41
|
+
## [0.28.9](https://github.com/webpack-contrib/css-loader/compare/v0.28.8...v0.28.9) (2018-01-17)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* ignore invalid URLs (`url()`) ([#663](https://github.com/webpack-contrib/css-loader/issues/663)) ([d1d8221](https://github.com/webpack-contrib/css-loader/commit/d1d8221))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
5
50
|
<a name="0.28.8"></a>
|
|
6
51
|
## [0.28.8](https://github.com/webpack-contrib/css-loader/compare/v0.28.7...v0.28.8) (2018-01-05)
|
|
7
52
|
|
package/README.md
CHANGED
|
@@ -94,37 +94,13 @@ It's useful when you, for instance, need to post process the CSS as a string.
|
|
|
94
94
|
|
|
95
95
|
|Name|Type|Default|Description|
|
|
96
96
|
|:--:|:--:|:-----:|:----------|
|
|
97
|
-
|**[`root`](#root)**|`{String}`|`/`|Path to resolve URLs, URLs starting with `/` will not be translated|
|
|
98
97
|
|**[`url`](#url)**|`{Boolean}`|`true`| Enable/Disable `url()` handling|
|
|
99
|
-
|**[`alias`](#alias)**|`{Object}`|`{}`|Create aliases to import certain modules more easily|
|
|
100
98
|
|**[`import`](#import)** |`{Boolean}`|`true`| Enable/Disable @import handling|
|
|
101
99
|
|**[`modules`](#modules)**|`{Boolean}`|`false`|Enable/Disable CSS Modules|
|
|
102
|
-
|**[`
|
|
100
|
+
|**[`localIdentName`](#localidentname)**|`{String}`|`[hash:base64]`|Configure the generated ident|
|
|
103
101
|
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
|
|
104
102
|
|**[`camelCase`](#camelcase)**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase|
|
|
105
103
|
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`|Number of loaders applied before CSS loader|
|
|
106
|
-
|**`localIdentName`**|`{String}`|`[hash:base64]`|Configure the generated ident|
|
|
107
|
-
|
|
108
|
-
### `root`
|
|
109
|
-
|
|
110
|
-
For URLs that start with a `/`, the default behavior is to not translate them.
|
|
111
|
-
|
|
112
|
-
`url(/image.png) => url(/image.png)`
|
|
113
|
-
|
|
114
|
-
If a `root` query parameter is set, however, it will be prepended to the URL
|
|
115
|
-
and then translated.
|
|
116
|
-
|
|
117
|
-
**webpack.config.js**
|
|
118
|
-
```js
|
|
119
|
-
{
|
|
120
|
-
loader: 'css-loader',
|
|
121
|
-
options: { root: '.' }
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
`url(/image.png)` => `require('./image.png')`
|
|
126
|
-
|
|
127
|
-
Using 'Root-relative' urls is not recommended. You should only use it for legacy CSS files.
|
|
128
104
|
|
|
129
105
|
### `url`
|
|
130
106
|
|
|
@@ -137,48 +113,6 @@ url(image.png) => require('./image.png')
|
|
|
137
113
|
url(~module/image.png) => require('module/image.png')
|
|
138
114
|
```
|
|
139
115
|
|
|
140
|
-
### `alias`
|
|
141
|
-
|
|
142
|
-
Rewrite your urls with alias, this is useful when it's hard to change url paths of your input files, for example, when you're using some css / sass files in another package (bootstrap, ratchet, font-awesome, etc.).
|
|
143
|
-
|
|
144
|
-
`css-loader`'s `alias` follows the same syntax as webpack's `resolve.alias`, you can see the details at the [resolve docs](https://webpack.js.org/configuration/resolve/#resolve-alias)
|
|
145
|
-
|
|
146
|
-
**file.scss**
|
|
147
|
-
```css
|
|
148
|
-
@charset "UTF-8";
|
|
149
|
-
@import "bootstrap";
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**webpack.config.js**
|
|
153
|
-
```js
|
|
154
|
-
{
|
|
155
|
-
test: /\.scss$/,
|
|
156
|
-
use: [
|
|
157
|
-
{
|
|
158
|
-
loader: "style-loader"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
loader: "css-loader",
|
|
162
|
-
options: {
|
|
163
|
-
alias: {
|
|
164
|
-
"../fonts/bootstrap": "bootstrap-sass/assets/fonts/bootstrap"
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
loader: "sass-loader",
|
|
170
|
-
options: {
|
|
171
|
-
includePaths: [
|
|
172
|
-
path.resolve("./node_modules/bootstrap-sass/assets/stylesheets")
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-bootstrap-sass-sample).
|
|
181
|
-
|
|
182
116
|
### `import`
|
|
183
117
|
|
|
184
118
|
To disable `@import` resolving by `css-loader` set the option to `false`
|
|
@@ -219,7 +153,7 @@ The loader replaces local selectors with unique identifiers. The choosen unique
|
|
|
219
153
|
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; }
|
|
220
154
|
```
|
|
221
155
|
|
|
222
|
-
>
|
|
156
|
+
> ℹ️ Identifiers are exported
|
|
223
157
|
|
|
224
158
|
```js
|
|
225
159
|
exports.locals = {
|
|
@@ -238,41 +172,6 @@ file.png => ./file.png
|
|
|
238
172
|
```
|
|
239
173
|
|
|
240
174
|
You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.
|
|
241
|
-
You can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`).
|
|
242
|
-
|
|
243
|
-
**webpack.config.js**
|
|
244
|
-
```js
|
|
245
|
-
{
|
|
246
|
-
test: /\.css$/,
|
|
247
|
-
use: [
|
|
248
|
-
{
|
|
249
|
-
loader: 'css-loader',
|
|
250
|
-
options: {
|
|
251
|
-
modules: true,
|
|
252
|
-
localIdentName: '[path][name]__[local]--[hash:base64:5]'
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
}
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object).
|
|
260
|
-
|
|
261
|
-
**webpack.config.js**
|
|
262
|
-
```js
|
|
263
|
-
{
|
|
264
|
-
loader: 'css-loader',
|
|
265
|
-
options: {
|
|
266
|
-
modules: true,
|
|
267
|
-
localIdentName: '[path][name]__[local]--[hash:base64:5]',
|
|
268
|
-
getLocalIdent: (context, localIdentName, localName, options) => {
|
|
269
|
-
return 'whatever_random_class_name'
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
> :information_source: For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings.
|
|
276
175
|
|
|
277
176
|
#### `Composing`
|
|
278
177
|
|
|
@@ -339,24 +238,44 @@ To import from multiple modules use multiple `composes:` rules.
|
|
|
339
238
|
}
|
|
340
239
|
```
|
|
341
240
|
|
|
342
|
-
### `
|
|
241
|
+
### `localIdentName`
|
|
343
242
|
|
|
344
|
-
|
|
243
|
+
You can configure the generated ident with the `localIdentName` query parameter. See [loader-utils's documentation](https://github.com/webpack/loader-utils#interpolatename) for more information on options.
|
|
345
244
|
|
|
346
|
-
|
|
245
|
+
**webpack.config.js**
|
|
246
|
+
```js
|
|
247
|
+
{
|
|
248
|
+
test: /\.css$/,
|
|
249
|
+
use: [
|
|
250
|
+
{
|
|
251
|
+
loader: 'css-loader',
|
|
252
|
+
options: {
|
|
253
|
+
modules: true,
|
|
254
|
+
localIdentName: '[path][name]__[local]--[hash:base64:5]'
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
347
260
|
|
|
348
|
-
You can also
|
|
261
|
+
You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object).
|
|
349
262
|
|
|
350
263
|
**webpack.config.js**
|
|
351
264
|
```js
|
|
352
265
|
{
|
|
353
266
|
loader: 'css-loader',
|
|
354
267
|
options: {
|
|
355
|
-
|
|
268
|
+
modules: true,
|
|
269
|
+
localIdentName: '[path][name]__[local]--[hash:base64:5]',
|
|
270
|
+
getLocalIdent: (context, localIdentName, localName, options) => {
|
|
271
|
+
return 'whatever_random_class_name'
|
|
272
|
+
}
|
|
356
273
|
}
|
|
357
274
|
}
|
|
358
275
|
```
|
|
359
276
|
|
|
277
|
+
> ℹ️ For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings.
|
|
278
|
+
|
|
360
279
|
### `sourceMap`
|
|
361
280
|
|
|
362
281
|
To include source maps set the `sourceMap` option.
|
|
@@ -459,37 +378,8 @@ module.exports = {
|
|
|
459
378
|
|
|
460
379
|
### Extract
|
|
461
380
|
|
|
462
|
-
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
|
|
463
|
-
|
|
464
|
-
**webpack.config.js**
|
|
465
|
-
```js
|
|
466
|
-
const env = process.env.NODE_ENV
|
|
467
|
-
|
|
468
|
-
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
469
|
-
|
|
470
|
-
module.exports = {
|
|
471
|
-
module: {
|
|
472
|
-
rules: [
|
|
473
|
-
{
|
|
474
|
-
test: /\.css$/,
|
|
475
|
-
use: env === 'production'
|
|
476
|
-
? ExtractTextPlugin.extract({
|
|
477
|
-
fallback: 'style-loader',
|
|
478
|
-
use: [ 'css-loader' ]
|
|
479
|
-
})
|
|
480
|
-
: [ 'style-loader', 'css-loader' ]
|
|
481
|
-
},
|
|
482
|
-
]
|
|
483
|
-
},
|
|
484
|
-
plugins: env === 'production'
|
|
485
|
-
? [
|
|
486
|
-
new ExtractTextPlugin({
|
|
487
|
-
filename: '[name].css'
|
|
488
|
-
})
|
|
489
|
-
]
|
|
490
|
-
: []
|
|
491
|
-
}
|
|
492
|
-
```
|
|
381
|
+
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
|
|
382
|
+
This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract the CSS when running in production mode.
|
|
493
383
|
|
|
494
384
|
<h2 align="center">Maintainers</h2>
|
|
495
385
|
|
package/lib/getLocalIdent.js
CHANGED
|
@@ -6,8 +6,15 @@ var loaderUtils = require("loader-utils");
|
|
|
6
6
|
var path = require("path");
|
|
7
7
|
|
|
8
8
|
module.exports = function getLocalIdent(loaderContext, localIdentName, localName, options) {
|
|
9
|
-
if(!options.context)
|
|
10
|
-
|
|
9
|
+
if(!options.context) {
|
|
10
|
+
if (loaderContext.rootContext) {
|
|
11
|
+
options.context = loaderContext.rootContext;
|
|
12
|
+
} else if (loaderContext.options && typeof loaderContext.options.context === "string") {
|
|
13
|
+
options.context = loaderContext.options.context;
|
|
14
|
+
} else {
|
|
15
|
+
options.context = loaderContext.context;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
var request = path.relative(options.context, loaderContext.resourcePath);
|
|
12
19
|
options.content = options.hashPrefix + request + "+" + localName;
|
|
13
20
|
localIdentName = localIdentName.replace(/\[local\]/gi, localName);
|
package/lib/loader.js
CHANGED
|
@@ -6,18 +6,14 @@ var loaderUtils = require("loader-utils");
|
|
|
6
6
|
var processCss = require("./processCss");
|
|
7
7
|
var getImportPrefix = require("./getImportPrefix");
|
|
8
8
|
var compileExports = require("./compile-exports");
|
|
9
|
-
var createResolver = require("./createResolver");
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
module.exports = function(content, map) {
|
|
13
|
-
if(this.cacheable) this.cacheable();
|
|
14
12
|
var callback = this.async();
|
|
15
13
|
var query = loaderUtils.getOptions(this) || {};
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var camelCaseKeys = query.camelCase || query.camelcase;
|
|
14
|
+
var moduleMode = query.modules;
|
|
15
|
+
var camelCaseKeys = query.camelCase;
|
|
19
16
|
var sourceMap = query.sourceMap || false;
|
|
20
|
-
var resolve = createResolver(query.alias);
|
|
21
17
|
|
|
22
18
|
if(sourceMap) {
|
|
23
19
|
if (map) {
|
|
@@ -42,8 +38,6 @@ module.exports = function(content, map) {
|
|
|
42
38
|
from: loaderUtils.getRemainingRequest(this).split("!").pop(),
|
|
43
39
|
to: loaderUtils.getCurrentRequest(this).split("!").pop(),
|
|
44
40
|
query: query,
|
|
45
|
-
resolve: resolve,
|
|
46
|
-
minimize: this.minimize,
|
|
47
41
|
loaderContext: this,
|
|
48
42
|
sourceMap: sourceMap
|
|
49
43
|
}, function(err, result) {
|
|
@@ -63,7 +57,7 @@ module.exports = function(content, map) {
|
|
|
63
57
|
}
|
|
64
58
|
return true;
|
|
65
59
|
}).map(function(imp) {
|
|
66
|
-
if(!loaderUtils.isUrlRequest(imp.url
|
|
60
|
+
if(!loaderUtils.isUrlRequest(imp.url)) {
|
|
67
61
|
return "exports.push([module.id, " +
|
|
68
62
|
JSON.stringify("@import url(" + imp.url + ");") + ", " +
|
|
69
63
|
JSON.stringify(imp.mediaQuery) + "]);";
|
|
@@ -94,7 +88,7 @@ module.exports = function(content, map) {
|
|
|
94
88
|
var match = result.urlItemRegExp.exec(item);
|
|
95
89
|
var idx = +match[1];
|
|
96
90
|
var urlItem = result.urlItems[idx];
|
|
97
|
-
var url =
|
|
91
|
+
var url = urlItem.url;
|
|
98
92
|
idx = url.indexOf("?#");
|
|
99
93
|
if(idx < 0) idx = url.indexOf("#");
|
|
100
94
|
var urlRequest;
|
|
@@ -108,7 +102,7 @@ module.exports = function(content, map) {
|
|
|
108
102
|
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"";
|
|
109
103
|
}.bind(this));
|
|
110
104
|
}
|
|
111
|
-
|
|
105
|
+
|
|
112
106
|
var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys);
|
|
113
107
|
if (exportJs) {
|
|
114
108
|
exportJs = "exports.locals = " + exportJs + ";";
|
package/lib/localsLoader.js
CHANGED
|
@@ -6,23 +6,18 @@ var loaderUtils = require("loader-utils");
|
|
|
6
6
|
var processCss = require("./processCss");
|
|
7
7
|
var getImportPrefix = require("./getImportPrefix");
|
|
8
8
|
var compileExports = require("./compile-exports");
|
|
9
|
-
var createResolver = require("./createResolver");
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
module.exports = function(content) {
|
|
13
|
-
if(this.cacheable) this.cacheable();
|
|
14
12
|
var callback = this.async();
|
|
15
13
|
var query = loaderUtils.getOptions(this) || {};
|
|
16
|
-
var moduleMode = query.modules
|
|
17
|
-
var camelCaseKeys = query.camelCase
|
|
18
|
-
var resolve = createResolver(query.alias);
|
|
14
|
+
var moduleMode = query.modules;
|
|
15
|
+
var camelCaseKeys = query.camelCase;
|
|
19
16
|
|
|
20
17
|
processCss(content, null, {
|
|
21
18
|
mode: moduleMode ? "local" : "global",
|
|
22
19
|
query: query,
|
|
23
|
-
minimize: this.minimize,
|
|
24
20
|
loaderContext: this,
|
|
25
|
-
resolve: resolve
|
|
26
21
|
}, function(err, result) {
|
|
27
22
|
if(err) return callback(err);
|
|
28
23
|
|
package/lib/processCss.js
CHANGED
|
@@ -6,7 +6,6 @@ var formatCodeFrame = require("babel-code-frame");
|
|
|
6
6
|
var Tokenizer = require("css-selector-tokenizer");
|
|
7
7
|
var postcss = require("postcss");
|
|
8
8
|
var loaderUtils = require("loader-utils");
|
|
9
|
-
var assign = require("object-assign");
|
|
10
9
|
var getLocalIdent = require("./getLocalIdent");
|
|
11
10
|
|
|
12
11
|
var icssUtils = require('icss-utils');
|
|
@@ -55,9 +54,11 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
55
54
|
}
|
|
56
55
|
values.nodes[0].nodes.shift();
|
|
57
56
|
var mediaQuery = Tokenizer.stringifyValues(values);
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
|
|
58
|
+
if(loaderUtils.isUrlRequest(url)) {
|
|
59
|
+
url = loaderUtils.urlToRequest(url);
|
|
60
60
|
}
|
|
61
|
+
|
|
61
62
|
importItems.push({
|
|
62
63
|
url: url,
|
|
63
64
|
mediaQuery: mediaQuery
|
|
@@ -83,11 +84,6 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
83
84
|
exports[exportName] = replaceImportsInString(exports[exportName]);
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
function isAlias(url) {
|
|
87
|
-
// Handle alias starting by / and root disabled
|
|
88
|
-
return url !== options.resolve(url)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
87
|
function processNode(item) {
|
|
92
88
|
switch (item.type) {
|
|
93
89
|
case "value":
|
|
@@ -103,7 +99,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
103
99
|
}
|
|
104
100
|
break;
|
|
105
101
|
case "url":
|
|
106
|
-
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) &&
|
|
102
|
+
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url)) {
|
|
107
103
|
// Strip quotes, they will be re-added if the module needs them
|
|
108
104
|
item.stringType = "";
|
|
109
105
|
delete item.innerSpacingBefore;
|
|
@@ -139,17 +135,13 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
139
135
|
|
|
140
136
|
module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
141
137
|
var query = options.query;
|
|
142
|
-
var root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, "") : query.root;
|
|
143
138
|
var context = query.context;
|
|
144
139
|
var localIdentName = query.localIdentName || "[hash:base64]";
|
|
145
140
|
var localIdentRegExp = query.localIdentRegExp;
|
|
146
|
-
var forceMinimize = query.minimize;
|
|
147
|
-
var minimize = typeof forceMinimize !== "undefined" ? !!forceMinimize : options.minimize;
|
|
148
141
|
|
|
149
142
|
var customGetLocalIdent = query.getLocalIdent || getLocalIdent;
|
|
150
143
|
|
|
151
144
|
var parserOptions = {
|
|
152
|
-
root: root,
|
|
153
145
|
mode: options.mode,
|
|
154
146
|
url: query.url !== false,
|
|
155
147
|
import: query.import !== false,
|
|
@@ -164,11 +156,11 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
|
164
156
|
if(parserOptions.url){
|
|
165
157
|
url = url.trim();
|
|
166
158
|
|
|
167
|
-
if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url
|
|
159
|
+
if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url)) {
|
|
168
160
|
return url;
|
|
169
161
|
}
|
|
170
162
|
if(global) {
|
|
171
|
-
return loaderUtils.urlToRequest(url
|
|
163
|
+
return loaderUtils.urlToRequest(url);
|
|
172
164
|
}
|
|
173
165
|
}
|
|
174
166
|
return url;
|
|
@@ -187,16 +179,6 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
|
187
179
|
parserPlugin(parserOptions)
|
|
188
180
|
]);
|
|
189
181
|
|
|
190
|
-
if(minimize) {
|
|
191
|
-
var cssnano = require("cssnano");
|
|
192
|
-
var minimizeOptions = assign({}, query.minimize);
|
|
193
|
-
["zindex", "normalizeUrl", "discardUnused", "mergeIdents", "reduceIdents", "autoprefixer"].forEach(function(name) {
|
|
194
|
-
if(typeof minimizeOptions[name] === "undefined")
|
|
195
|
-
minimizeOptions[name] = false;
|
|
196
|
-
});
|
|
197
|
-
pipeline.use(cssnano(minimizeOptions));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
182
|
pipeline.process(inputSource, {
|
|
201
183
|
// we need a prefix to avoid path rewriting of PostCSS
|
|
202
184
|
from: "/css-loader!" + options.from,
|
package/lib/url/escape.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"author": "Tobias Koppers @sokra",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "css loader module for webpack",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">= 6.9.0 <7.0.0 || >= 8.9.0"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"lib",
|
|
@@ -15,13 +15,11 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"babel-code-frame": "^6.26.0",
|
|
17
17
|
"css-selector-tokenizer": "^0.7.0",
|
|
18
|
-
"cssnano": "^3.10.0",
|
|
19
18
|
"icss-utils": "^2.1.0",
|
|
20
19
|
"loader-utils": "^1.0.2",
|
|
21
20
|
"lodash.camelcase": "^4.3.0",
|
|
22
|
-
"
|
|
23
|
-
"postcss": "^
|
|
24
|
-
"postcss-modules-extract-imports": "^1.1.0",
|
|
21
|
+
"postcss": "^6.0.23",
|
|
22
|
+
"postcss-modules-extract-imports": "^1.2.0",
|
|
25
23
|
"postcss-modules-local-by-default": "^1.2.0",
|
|
26
24
|
"postcss-modules-scope": "^1.1.0",
|
|
27
25
|
"postcss-modules-values": "^1.3.0",
|
|
@@ -36,6 +34,9 @@
|
|
|
36
34
|
"should": "^11.1.2",
|
|
37
35
|
"standard-version": "^4.0.0"
|
|
38
36
|
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"webpack": "^4.0.0"
|
|
39
|
+
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"lint": "eslint lib test",
|
|
41
42
|
"test": "mocha",
|
package/lib/createResolver.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module.exports = function createResolver(alias) {
|
|
2
|
-
if(typeof alias !== "object" || Array.isArray(alias)) {
|
|
3
|
-
return function(url) {
|
|
4
|
-
return url
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
alias = Object.keys(alias).map(function(key) {
|
|
9
|
-
var onlyModule = false;
|
|
10
|
-
var obj = alias[key];
|
|
11
|
-
if(/\$$/.test(key)) {
|
|
12
|
-
onlyModule = true;
|
|
13
|
-
key = key.substr(0, key.length - 1);
|
|
14
|
-
}
|
|
15
|
-
if(typeof obj === "string") {
|
|
16
|
-
obj = {
|
|
17
|
-
alias: obj
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
obj = Object.assign({
|
|
21
|
-
name: key,
|
|
22
|
-
onlyModule: onlyModule
|
|
23
|
-
}, obj);
|
|
24
|
-
return obj;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return function(url) {
|
|
28
|
-
alias.forEach(function(obj) {
|
|
29
|
-
var name = obj.name;
|
|
30
|
-
if(url === name || (!obj.onlyModule && url.startsWith(name + "/"))) {
|
|
31
|
-
url = obj.alias + url.substr(name.length);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return url;
|
|
35
|
-
}
|
|
36
|
-
}
|