css-loader 0.28.11 → 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 +15 -0
- package/README.md +29 -139
- package/lib/loader.js +5 -11
- package/lib/localsLoader.js +2 -7
- package/lib/processCss.js +5 -25
- package/package.json +6 -5
- package/lib/createResolver.js +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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
|
+
|
|
5
20
|
<a name="0.28.11"></a>
|
|
6
21
|
## [0.28.11](https://github.com/webpack-contrib/css-loader/compare/v0.28.10...v0.28.11) (2018-03-16)
|
|
7
22
|
|
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/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');
|
|
@@ -56,8 +55,8 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
56
55
|
values.nodes[0].nodes.shift();
|
|
57
56
|
var mediaQuery = Tokenizer.stringifyValues(values);
|
|
58
57
|
|
|
59
|
-
if(loaderUtils.isUrlRequest(url
|
|
60
|
-
url = loaderUtils.urlToRequest(url
|
|
58
|
+
if(loaderUtils.isUrlRequest(url)) {
|
|
59
|
+
url = loaderUtils.urlToRequest(url);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
importItems.push({
|
|
@@ -85,11 +84,6 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
85
84
|
exports[exportName] = replaceImportsInString(exports[exportName]);
|
|
86
85
|
});
|
|
87
86
|
|
|
88
|
-
function isAlias(url) {
|
|
89
|
-
// Handle alias starting by / and root disabled
|
|
90
|
-
return url !== options.resolve(url)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
87
|
function processNode(item) {
|
|
94
88
|
switch (item.type) {
|
|
95
89
|
case "value":
|
|
@@ -105,7 +99,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
105
99
|
}
|
|
106
100
|
break;
|
|
107
101
|
case "url":
|
|
108
|
-
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)) {
|
|
109
103
|
// Strip quotes, they will be re-added if the module needs them
|
|
110
104
|
item.stringType = "";
|
|
111
105
|
delete item.innerSpacingBefore;
|
|
@@ -141,17 +135,13 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
141
135
|
|
|
142
136
|
module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
143
137
|
var query = options.query;
|
|
144
|
-
var root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, "") : query.root;
|
|
145
138
|
var context = query.context;
|
|
146
139
|
var localIdentName = query.localIdentName || "[hash:base64]";
|
|
147
140
|
var localIdentRegExp = query.localIdentRegExp;
|
|
148
|
-
var forceMinimize = query.minimize;
|
|
149
|
-
var minimize = typeof forceMinimize !== "undefined" ? !!forceMinimize : options.minimize;
|
|
150
141
|
|
|
151
142
|
var customGetLocalIdent = query.getLocalIdent || getLocalIdent;
|
|
152
143
|
|
|
153
144
|
var parserOptions = {
|
|
154
|
-
root: root,
|
|
155
145
|
mode: options.mode,
|
|
156
146
|
url: query.url !== false,
|
|
157
147
|
import: query.import !== false,
|
|
@@ -166,11 +156,11 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
|
166
156
|
if(parserOptions.url){
|
|
167
157
|
url = url.trim();
|
|
168
158
|
|
|
169
|
-
if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url
|
|
159
|
+
if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url)) {
|
|
170
160
|
return url;
|
|
171
161
|
}
|
|
172
162
|
if(global) {
|
|
173
|
-
return loaderUtils.urlToRequest(url
|
|
163
|
+
return loaderUtils.urlToRequest(url);
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
return url;
|
|
@@ -189,16 +179,6 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
|
189
179
|
parserPlugin(parserOptions)
|
|
190
180
|
]);
|
|
191
181
|
|
|
192
|
-
if(minimize) {
|
|
193
|
-
var cssnano = require("cssnano");
|
|
194
|
-
var minimizeOptions = assign({}, query.minimize);
|
|
195
|
-
["zindex", "normalizeUrl", "discardUnused", "mergeIdents", "reduceIdents", "autoprefixer"].forEach(function(name) {
|
|
196
|
-
if(typeof minimizeOptions[name] === "undefined")
|
|
197
|
-
minimizeOptions[name] = false;
|
|
198
|
-
});
|
|
199
|
-
pipeline.use(cssnano(minimizeOptions));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
182
|
pipeline.process(inputSource, {
|
|
203
183
|
// we need a prefix to avoid path rewriting of PostCSS
|
|
204
184
|
from: "/css-loader!" + options.from,
|
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,12 +15,10 @@
|
|
|
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": "^5.0.6",
|
|
21
|
+
"postcss": "^6.0.23",
|
|
24
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",
|
|
@@ -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
|
-
}
|