css-loader 0.25.0 → 0.26.4
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/LICENSE +20 -0
- package/README.md +289 -101
- package/index.js +5 -5
- package/lib/compile-exports.js +38 -29
- package/lib/css-base.js +50 -50
- package/lib/getImportPrefix.js +14 -14
- package/lib/getLocalIdent.js +16 -16
- package/lib/loader.js +119 -124
- package/lib/localsLoader.js +46 -46
- package/lib/processCss.js +252 -251
- package/locals.js +5 -5
- package/package.json +20 -12
- package/.eslintrc +0 -10
- package/.npmignore +0 -3
- package/.travis.yml +0 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright JS Foundation and other contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,66 +1,148 @@
|
|
|
1
|
-
|
|
1
|
+
[![npm][npm]][npm-url]
|
|
2
|
+
[![node][node]][node-url]
|
|
3
|
+
[![deps][deps]][deps-url]
|
|
4
|
+
[![tests][tests]][tests-url]
|
|
5
|
+
[![coverage][cover]][cover-url]
|
|
6
|
+
[![chat][chat]][chat-url]
|
|
7
|
+
|
|
8
|
+
<div align="center">
|
|
9
|
+
<img width="200" height="200"
|
|
10
|
+
src="https://cdn.worldvectorlogo.com/logos/css-3.svg">
|
|
11
|
+
<a href="https://github.com/webpack/webpack">
|
|
12
|
+
<img width="200" height="200"
|
|
13
|
+
src="https://webpack.js.org/assets/icon-square-big.svg">
|
|
14
|
+
</a>
|
|
15
|
+
<h1>CSS Loader</h1>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<h2 align="center">Install</h2>
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install --save-dev css-loader
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
<h2 align="center">Usage</h2>
|
|
25
|
+
|
|
26
|
+
The `css-loader` interprets `@import` and `url()` like `requires`.
|
|
2
27
|
|
|
3
|
-
|
|
28
|
+
Use the loader either via your webpack config, CLI or inline.
|
|
4
29
|
|
|
5
|
-
|
|
30
|
+
### Via webpack config (recommended)
|
|
31
|
+
|
|
32
|
+
**webpack.config.js**
|
|
33
|
+
```js
|
|
34
|
+
module.exports = {
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
test: /\.css$/,
|
|
39
|
+
use: [ 'style-loader', 'css-loader' ]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**In your application**
|
|
47
|
+
```js
|
|
48
|
+
import css from 'file.css';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### CLI
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
webpack --module-bind 'css=style-loader!css-loader'
|
|
55
|
+
```
|
|
6
56
|
|
|
7
|
-
|
|
57
|
+
**In your application**
|
|
58
|
+
```js
|
|
59
|
+
import css from 'file.css';
|
|
60
|
+
```
|
|
8
61
|
|
|
9
|
-
|
|
62
|
+
### Inline
|
|
10
63
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
64
|
+
**In your application**
|
|
65
|
+
```js
|
|
66
|
+
import css from 'style-loader!css-loader!./file.css';
|
|
14
67
|
```
|
|
15
68
|
|
|
16
|
-
|
|
69
|
+
<h2 align="center">Options</h2>
|
|
70
|
+
|
|
71
|
+
`@import` and `url()` are interpreted like `import` and will be resolved by the css-loader.
|
|
17
72
|
Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)
|
|
18
73
|
and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see below).
|
|
19
74
|
|
|
20
75
|
To be compatible with existing css files (if not in CSS Module mode):
|
|
21
|
-
* `url(image.png)` => `require("./image.png")`
|
|
22
|
-
* `url(~module/image.png)` => `require("module/image.png")`
|
|
23
76
|
|
|
24
|
-
|
|
77
|
+
* `url(image.png)` => `require('./image.png')`
|
|
78
|
+
* `url(~module/image.png)` => `require('module/image.png')`
|
|
79
|
+
|
|
80
|
+
<h2 align="center">Options</h2>
|
|
25
81
|
|
|
26
|
-
|
|
82
|
+
|Name|Default|Description|
|
|
83
|
+
|:--:|:-----:|:----------|
|
|
84
|
+
|**`root`**|`/`|Path to resolve URLs, URLs starting with `/` will not be translated|
|
|
85
|
+
|**`modules`**|`false`|Enable/Disable CSS Modules|
|
|
86
|
+
|**`import`** |`true`| Enable/Disable @import handling|
|
|
87
|
+
|**`url`**|`true`| Enable/Disable `url()` handling|
|
|
88
|
+
|**`minimize`**|`false`|Enable/Disable minification|
|
|
89
|
+
|**`sourceMap`**|`false`|Enable/Disable Sourcemaps|
|
|
90
|
+
|**`camelCase`**|`false`|Export Classnames in CamelCase|
|
|
91
|
+
|**`importLoaders`**|`0`|Number of loaders applied before CSS loader|
|
|
27
92
|
|
|
28
|
-
|
|
93
|
+
The following webpack config can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory.
|
|
94
|
+
|
|
95
|
+
**webpack.config.js**
|
|
96
|
+
```js
|
|
29
97
|
module.exports = {
|
|
30
98
|
module: {
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
99
|
+
rules: [
|
|
100
|
+
{
|
|
101
|
+
test: /\.css$/,
|
|
102
|
+
use: [ 'style-loader', 'css-loader' ]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
|
|
106
|
+
loader: 'url-loader',
|
|
107
|
+
options: {
|
|
108
|
+
limit: 10000
|
|
109
|
+
}
|
|
110
|
+
}
|
|
35
111
|
]
|
|
36
112
|
}
|
|
37
113
|
};
|
|
38
114
|
```
|
|
39
115
|
|
|
40
|
-
###
|
|
116
|
+
### Root
|
|
117
|
+
|
|
118
|
+
For URLs that start with a `/`, the default behavior is to not translate them:
|
|
41
119
|
|
|
42
|
-
For urls that start with a `/`, the default behavior is to not translate them:
|
|
43
120
|
* `url(/image.png)` => `url(/image.png)`
|
|
44
121
|
|
|
45
|
-
If a `root` query parameter is set, however, it will be prepended to the
|
|
122
|
+
If a `root` query parameter is set, however, it will be prepended to the URL
|
|
46
123
|
and then translated:
|
|
47
124
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
125
|
+
**webpack.config.js**
|
|
126
|
+
```js
|
|
127
|
+
rules: [
|
|
128
|
+
{
|
|
129
|
+
test: /\.css$/,
|
|
130
|
+
use: [
|
|
131
|
+
'style-loader',
|
|
132
|
+
{
|
|
133
|
+
loader: 'css-loader',
|
|
134
|
+
options: { root: '.' }
|
|
135
|
+
}
|
|
54
136
|
]
|
|
137
|
+
}
|
|
138
|
+
]
|
|
55
139
|
```
|
|
56
140
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* `url(/image.png)` => `require("./image.png")`
|
|
141
|
+
* `url(/image.png)` => `require('./image.png')`
|
|
60
142
|
|
|
61
143
|
Using 'Root-relative' urls is not recommended. You should only use it for legacy CSS files.
|
|
62
144
|
|
|
63
|
-
###
|
|
145
|
+
### CSS Scope
|
|
64
146
|
|
|
65
147
|
By default CSS exports all class names into a global selector scope. Styles can be locally scoped to avoid globally scoping styles.
|
|
66
148
|
|
|
@@ -70,17 +152,15 @@ With `:local` (without brackets) local mode can be switched on for this selector
|
|
|
70
152
|
|
|
71
153
|
The loader replaces local selectors with unique identifiers. The choosen unique identifiers are exported by the module.
|
|
72
154
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
``` css
|
|
155
|
+
**app.css**
|
|
156
|
+
```css
|
|
76
157
|
:local(.className) { background: red; }
|
|
77
158
|
:local .className { color: green; }
|
|
78
159
|
:local(.className .subClass) { color: green; }
|
|
79
160
|
:local .className .subClass :global(.global-class-name) { color: blue; }
|
|
80
161
|
```
|
|
81
162
|
|
|
82
|
-
|
|
83
|
-
|
|
163
|
+
**app.bundle.css**
|
|
84
164
|
``` css
|
|
85
165
|
._23_aKvs-b8bW2Vg3fwHozO { background: red; }
|
|
86
166
|
._23_aKvs-b8bW2Vg3fwHozO { color: green; }
|
|
@@ -88,37 +168,71 @@ is transformed to
|
|
|
88
168
|
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; }
|
|
89
169
|
```
|
|
90
170
|
|
|
91
|
-
|
|
171
|
+
> Note: Identifiers are exported
|
|
92
172
|
|
|
93
173
|
``` js
|
|
94
174
|
exports.locals = {
|
|
95
|
-
className:
|
|
96
|
-
subClass:
|
|
175
|
+
className: '_23_aKvs-b8bW2Vg3fwHozO',
|
|
176
|
+
subClass: '_13LGdX8RMStbBE9w-t0gZ1'
|
|
97
177
|
}
|
|
98
178
|
```
|
|
99
179
|
|
|
100
|
-
|
|
180
|
+
CamelCase is recommended for local selectors. They are easier to use in the within the imported JS module.
|
|
101
181
|
|
|
102
|
-
`url(
|
|
103
|
-
* `./file.png` instead of `file.png`
|
|
104
|
-
* `module/file.png` instead of `~module/file.png`
|
|
182
|
+
`url()` URLs in block scoped (`:local .abc`) rules behave like requests in modules:
|
|
105
183
|
|
|
184
|
+
* `./file.png` instead of `file.png`
|
|
185
|
+
* `module/file.png` instead of `~module/file.png`
|
|
106
186
|
|
|
107
187
|
You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.
|
|
108
188
|
|
|
109
|
-
You can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`).
|
|
189
|
+
You can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`).
|
|
190
|
+
|
|
191
|
+
**webpack.config.js**
|
|
192
|
+
```js
|
|
193
|
+
{
|
|
194
|
+
test: /\.css$/,
|
|
195
|
+
use: [
|
|
196
|
+
{
|
|
197
|
+
loader: 'css-loader',
|
|
198
|
+
options: {
|
|
199
|
+
modules: true,
|
|
200
|
+
localIdentName: '[path][name]__[local]--[hash:base64:5]'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. Note that this requires `webpack >= v2.x.` since to be able to pass function in. For example:
|
|
110
208
|
|
|
111
|
-
|
|
209
|
+
```js
|
|
210
|
+
{
|
|
211
|
+
test: /\.css$/,
|
|
212
|
+
use: [
|
|
213
|
+
{
|
|
214
|
+
loader: 'css-loader',
|
|
215
|
+
options: {
|
|
216
|
+
modules: true,
|
|
217
|
+
localIdentName: '[path][name]__[local]--[hash:base64:5]',
|
|
218
|
+
getLocalIdent: (context, localIdentName, localName, options) => {
|
|
219
|
+
return 'whatever_random_class_name'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
```
|
|
112
226
|
|
|
113
|
-
|
|
227
|
+
Note: 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.
|
|
114
228
|
|
|
115
|
-
|
|
229
|
+
### [CSS Modules](https://github.com/css-modules/css-modules)
|
|
116
230
|
|
|
117
|
-
The query parameter `modules` enables the **CSS Modules** spec.
|
|
231
|
+
The query parameter `modules` enables the **CSS Modules** spec.
|
|
118
232
|
|
|
119
|
-
This enables
|
|
233
|
+
This enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.)
|
|
120
234
|
|
|
121
|
-
###
|
|
235
|
+
### CSS Composing
|
|
122
236
|
|
|
123
237
|
When declaring a local class name you can compose a local class from another local class name.
|
|
124
238
|
|
|
@@ -136,15 +250,13 @@ When declaring a local class name you can compose a local class from another loc
|
|
|
136
250
|
|
|
137
251
|
This doesn't result in any change to the CSS itself but exports multiple class names:
|
|
138
252
|
|
|
139
|
-
```
|
|
253
|
+
```js
|
|
140
254
|
exports.locals = {
|
|
141
|
-
className:
|
|
142
|
-
subClass:
|
|
255
|
+
className: '_23_aKvs-b8bW2Vg3fwHozO',
|
|
256
|
+
subClass: '_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO'
|
|
143
257
|
}
|
|
144
258
|
```
|
|
145
259
|
|
|
146
|
-
and CSS is transformed to:
|
|
147
|
-
|
|
148
260
|
``` css
|
|
149
261
|
._23_aKvs-b8bW2Vg3fwHozO {
|
|
150
262
|
background: red;
|
|
@@ -156,20 +268,20 @@ and CSS is transformed to:
|
|
|
156
268
|
}
|
|
157
269
|
```
|
|
158
270
|
|
|
159
|
-
### Importing
|
|
271
|
+
### Importing CSS Locals
|
|
160
272
|
|
|
161
273
|
To import a local class name from another module:
|
|
162
274
|
|
|
163
275
|
``` css
|
|
164
276
|
:local(.continueButton) {
|
|
165
|
-
composes: button from
|
|
277
|
+
composes: button from 'library/button.css';
|
|
166
278
|
background: red;
|
|
167
279
|
}
|
|
168
280
|
```
|
|
169
281
|
|
|
170
282
|
``` css
|
|
171
283
|
:local(.nameEdit) {
|
|
172
|
-
composes: edit highlight from
|
|
284
|
+
composes: edit highlight from './edit.css';
|
|
173
285
|
background: red;
|
|
174
286
|
}
|
|
175
287
|
```
|
|
@@ -178,8 +290,8 @@ To import from multiple modules use multiple `composes:` rules.
|
|
|
178
290
|
|
|
179
291
|
``` css
|
|
180
292
|
:local(.className) {
|
|
181
|
-
composes: edit hightlight from
|
|
182
|
-
composes: button from
|
|
293
|
+
composes: edit hightlight from './edit.css';
|
|
294
|
+
composes: button from 'module/button.css';
|
|
183
295
|
composes: classFromThisModule;
|
|
184
296
|
background: red;
|
|
185
297
|
}
|
|
@@ -187,30 +299,47 @@ To import from multiple modules use multiple `composes:` rules.
|
|
|
187
299
|
|
|
188
300
|
### SourceMaps
|
|
189
301
|
|
|
190
|
-
To include
|
|
191
|
-
|
|
192
|
-
`require("css-loader?sourceMap!./file.css")`
|
|
302
|
+
To include Sourcemaps set the `sourceMap` query param.
|
|
193
303
|
|
|
194
304
|
I. e. the extract-text-webpack-plugin can handle them.
|
|
195
305
|
|
|
196
|
-
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS SourceMap do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server
|
|
306
|
+
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS SourceMap do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server URL.
|
|
197
307
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
308
|
+
**webpack.config.js**
|
|
309
|
+
```js
|
|
310
|
+
{
|
|
311
|
+
test: /\.css$/,
|
|
312
|
+
use: [
|
|
313
|
+
{
|
|
314
|
+
loader: 'css-loader',
|
|
315
|
+
options: {
|
|
316
|
+
sourceMap: true
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
```
|
|
201
322
|
|
|
202
|
-
|
|
323
|
+
### ImportLoaders
|
|
203
324
|
|
|
204
|
-
|
|
325
|
+
The query parameter `importLoaders` allow to configure which loaders should be applied to `@import`ed resources.
|
|
205
326
|
|
|
206
|
-
|
|
207
|
-
require("style-loader!css-loader?importLoaders=1!autoprefixer-loader!...")
|
|
208
|
-
// => imported resources are handled this way:
|
|
209
|
-
require("css-loader?importLoaders=1!autoprefixer-loader!...")
|
|
327
|
+
`importLoaders`: That many loaders after the css-loader are used to import resources.
|
|
210
328
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
329
|
+
**webpack.config.js**
|
|
330
|
+
```js
|
|
331
|
+
{
|
|
332
|
+
test: /\.css$/,
|
|
333
|
+
use: [
|
|
334
|
+
{
|
|
335
|
+
loader: 'css-loader',
|
|
336
|
+
options: {
|
|
337
|
+
importLoaders: 1
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
'postcss-loader'
|
|
341
|
+
]
|
|
342
|
+
}
|
|
214
343
|
```
|
|
215
344
|
|
|
216
345
|
This may change in the future, when the module system (i. e. webpack) supports loader matching by origin.
|
|
@@ -219,41 +348,100 @@ This may change in the future, when the module system (i. e. webpack) supports l
|
|
|
219
348
|
|
|
220
349
|
By default the css-loader minimizes the css if specified by the module system.
|
|
221
350
|
|
|
222
|
-
In some cases the minification is destructive to the css, so you can provide some options to it. cssnano is used for minification and you find a [list of options here](http://cssnano.co/options/).
|
|
351
|
+
In some cases the minification is destructive to the css, so you can provide some options to it. cssnano is used for minification and you find a [list of options here](http://cssnano.co/options/).
|
|
223
352
|
|
|
224
353
|
You can also disable or enforce minification with the `minimize` query parameter.
|
|
225
354
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
355
|
+
**webpack.config.js**
|
|
356
|
+
```js
|
|
357
|
+
{
|
|
358
|
+
test: /\.css$/,
|
|
359
|
+
use: [
|
|
360
|
+
{
|
|
361
|
+
loader: 'css-loader',
|
|
362
|
+
options: {
|
|
363
|
+
minimize: true || {/* CSSNano Options */}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
```
|
|
237
369
|
|
|
238
|
-
|
|
370
|
+
### CamelCase
|
|
239
371
|
|
|
240
|
-
|
|
372
|
+
By default, the exported JSON keys mirror the class names. If you want to camelize class names (useful in JS), pass the query parameter `camelCase` to css-loader.
|
|
241
373
|
|
|
242
|
-
|
|
374
|
+
**webpack.config.js**
|
|
375
|
+
```js
|
|
376
|
+
{
|
|
377
|
+
test: /\.css$/,
|
|
378
|
+
use: [
|
|
379
|
+
{
|
|
380
|
+
loader: 'css-loader',
|
|
381
|
+
options: {
|
|
382
|
+
camelCase: true
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
```
|
|
243
388
|
|
|
244
|
-
Usage:
|
|
245
389
|
```css
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
.class-name { /* ... */ }
|
|
390
|
+
.class-name {}
|
|
249
391
|
```
|
|
250
392
|
|
|
251
393
|
```js
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
require('file.css').className
|
|
394
|
+
import { className } from 'file.css';
|
|
255
395
|
```
|
|
256
396
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
397
|
+
<h2 align="center">Maintainers</h2>
|
|
398
|
+
|
|
399
|
+
<table>
|
|
400
|
+
<tbody>
|
|
401
|
+
<tr>
|
|
402
|
+
<td align="center">
|
|
403
|
+
<img width="150" height="150"
|
|
404
|
+
src="https://avatars3.githubusercontent.com/u/166921?v=3&s=150">
|
|
405
|
+
</br>
|
|
406
|
+
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
|
|
407
|
+
</td>
|
|
408
|
+
<td align="center">
|
|
409
|
+
<img width="150" height="150"
|
|
410
|
+
src="https://avatars2.githubusercontent.com/u/8420490?v=3&s=150">
|
|
411
|
+
</br>
|
|
412
|
+
<a href="https://github.com/d3viant0ne">Joshua Wiens</a>
|
|
413
|
+
</td>
|
|
414
|
+
<td align="center">
|
|
415
|
+
<img width="150" height="150"
|
|
416
|
+
src="https://avatars3.githubusercontent.com/u/533616?v=3&s=150">
|
|
417
|
+
</br>
|
|
418
|
+
<a href="https://github.com/SpaceK33z">Kees Kluskens</a>
|
|
419
|
+
</td>
|
|
420
|
+
<td align="center">
|
|
421
|
+
<img width="150" height="150"
|
|
422
|
+
src="https://avatars3.githubusercontent.com/u/3408176?v=3&s=150">
|
|
423
|
+
</br>
|
|
424
|
+
<a href="https://github.com/TheLarkInn">Sean Larkin</a>
|
|
425
|
+
</td>
|
|
426
|
+
</tr>
|
|
427
|
+
<tbody>
|
|
428
|
+
</table>
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
[npm]: https://img.shields.io/npm/v/css-loader.svg
|
|
432
|
+
[npm-url]: https://npmjs.com/package/css-loader
|
|
433
|
+
|
|
434
|
+
[node]: https://img.shields.io/node/v/css-loader.svg
|
|
435
|
+
[node-url]: https://nodejs.org
|
|
436
|
+
|
|
437
|
+
[deps]: https://david-dm.org/webpack/css-loader.svg
|
|
438
|
+
[deps-url]: https://david-dm.org/webpack/css-loader
|
|
439
|
+
|
|
440
|
+
[tests]: http://img.shields.io/travis/webpack/css-loader.svg
|
|
441
|
+
[tests-url]: https://travis-ci.org/webpack/css-loader
|
|
442
|
+
|
|
443
|
+
[cover]: https://coveralls.io/repos/github/webpack/css-loader/badge.svg
|
|
444
|
+
[cover-url]: https://coveralls.io/github/webpack/css-loader
|
|
445
|
+
|
|
446
|
+
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
|
447
|
+
[chat-url]: https://gitter.im/webpack/webpack
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
module.exports = require("./lib/loader");
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
module.exports = require("./lib/loader");
|
package/lib/compile-exports.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
var camelCase = require("lodash.camelcase");
|
|
2
|
-
|
|
3
|
-
function dashesCamelCase(str) {
|
|
4
|
-
return str.replace(/-(\w)/g, function(match, firstLetter) {
|
|
5
|
-
return firstLetter.toUpperCase();
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = function compileExports(result, importItemMatcher, camelCaseKeys) {
|
|
10
|
-
if (!Object.keys(result.exports).length) {
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var exportJs = Object.keys(result.exports).reduce(function(res, key) {
|
|
15
|
-
var valueAsString = JSON.stringify(result.exports[key]);
|
|
16
|
-
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
var camelCase = require("lodash.camelcase");
|
|
2
|
+
|
|
3
|
+
function dashesCamelCase(str) {
|
|
4
|
+
return str.replace(/-(\w)/g, function(match, firstLetter) {
|
|
5
|
+
return firstLetter.toUpperCase();
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = function compileExports(result, importItemMatcher, camelCaseKeys) {
|
|
10
|
+
if (!Object.keys(result.exports).length) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var exportJs = Object.keys(result.exports).reduce(function(res, key) {
|
|
15
|
+
var valueAsString = JSON.stringify(result.exports[key]);
|
|
16
|
+
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher);
|
|
17
|
+
function addEntry(k) {
|
|
18
|
+
res.push("\t" + JSON.stringify(k) + ": " + valueAsString);
|
|
19
|
+
}
|
|
20
|
+
addEntry(key);
|
|
21
|
+
|
|
22
|
+
var targetKey;
|
|
23
|
+
if (camelCaseKeys === true) {
|
|
24
|
+
targetKey = camelCase(key);
|
|
25
|
+
if (targetKey !== key) {
|
|
26
|
+
addEntry(targetKey);
|
|
27
|
+
}
|
|
28
|
+
} else if (camelCaseKeys === 'dashes') {
|
|
29
|
+
targetKey = dashesCamelCase(key);
|
|
30
|
+
if (targetKey !== key) {
|
|
31
|
+
addEntry(targetKey);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return res;
|
|
35
|
+
}, []).join(",\n");
|
|
36
|
+
|
|
37
|
+
return "{\n" + exportJs + "\n}";
|
|
38
|
+
};
|