css-loader 6.1.0 → 6.5.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/README.md +302 -72
- package/dist/index.js +32 -32
- package/dist/options.json +18 -6
- package/dist/plugins/index.js +4 -4
- package/dist/plugins/postcss-icss-parser.js +14 -7
- package/dist/plugins/postcss-import-parser.js +93 -23
- package/dist/plugins/postcss-url-parser.js +47 -42
- package/dist/runtime/api.js +53 -17
- package/dist/runtime/getUrl.js +1 -5
- package/dist/runtime/noSourceMaps.js +5 -0
- package/dist/runtime/sourceMaps.js +22 -0
- package/dist/utils.js +302 -151
- package/package.json +6 -6
- package/dist/runtime/cssWithMappingToString.js +0 -36
|
@@ -11,7 +11,7 @@ var _utils = require("../utils");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
function parseNode(atRule, key) {
|
|
14
|
+
function parseNode(atRule, key, options) {
|
|
15
15
|
// Convert only top-level @import
|
|
16
16
|
if (atRule.parent.type !== "root") {
|
|
17
17
|
return;
|
|
@@ -43,9 +43,10 @@ function parseNode(atRule, key) {
|
|
|
43
43
|
throw error;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const rawParams = atRule.raws && atRule.raws[key] && typeof atRule.raws[key].raw !== "undefined" ? atRule.raws[key].raw : atRule[key];
|
|
46
47
|
const {
|
|
47
48
|
nodes: paramsNodes
|
|
48
|
-
} = (0, _postcssValueParser.default)(
|
|
49
|
+
} = (0, _postcssValueParser.default)(rawParams); // No nodes - `@import ;`
|
|
49
50
|
// Invalid type - `@import foo-bar;`
|
|
50
51
|
|
|
51
52
|
if (paramsNodes.length === 0 || paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function") {
|
|
@@ -73,10 +74,13 @@ function parseNode(atRule, key) {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
url = (0, _utils.normalizeUrl)(url, isStringValue);
|
|
76
|
-
const
|
|
77
|
+
const {
|
|
78
|
+
requestable,
|
|
79
|
+
needResolve
|
|
80
|
+
} = (0, _utils.isURLRequestable)(url, options);
|
|
77
81
|
let prefix;
|
|
78
82
|
|
|
79
|
-
if (
|
|
83
|
+
if (requestable && needResolve) {
|
|
80
84
|
const queryParts = url.split("!");
|
|
81
85
|
|
|
82
86
|
if (queryParts.length > 1) {
|
|
@@ -92,11 +96,42 @@ function parseNode(atRule, key) {
|
|
|
92
96
|
throw error;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
const
|
|
99
|
+
const additionalNodes = paramsNodes.slice(1);
|
|
100
|
+
let supports;
|
|
101
|
+
let layer;
|
|
96
102
|
let media;
|
|
97
103
|
|
|
98
|
-
if (
|
|
99
|
-
|
|
104
|
+
if (additionalNodes.length > 0) {
|
|
105
|
+
let nodes = [];
|
|
106
|
+
|
|
107
|
+
for (const node of additionalNodes) {
|
|
108
|
+
nodes.push(node);
|
|
109
|
+
const isLayerFunction = node.type === "function" && node.value.toLowerCase() === "layer";
|
|
110
|
+
const isLayerWord = node.type === "word" && node.value.toLowerCase() === "layer";
|
|
111
|
+
|
|
112
|
+
if (isLayerFunction || isLayerWord) {
|
|
113
|
+
if (isLayerFunction) {
|
|
114
|
+
nodes.splice(nodes.length - 1, 1, ...node.nodes);
|
|
115
|
+
} else {
|
|
116
|
+
nodes.splice(nodes.length - 1, 1, {
|
|
117
|
+
type: "string",
|
|
118
|
+
value: "",
|
|
119
|
+
unclosed: false
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
layer = _postcssValueParser.default.stringify(nodes).trim().toLowerCase();
|
|
124
|
+
nodes = [];
|
|
125
|
+
} else if (node.type === "function" && node.value.toLowerCase() === "supports") {
|
|
126
|
+
nodes.splice(nodes.length - 1, 1, ...node.nodes);
|
|
127
|
+
supports = _postcssValueParser.default.stringify(nodes).trim().toLowerCase();
|
|
128
|
+
nodes = [];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (nodes.length > 0) {
|
|
133
|
+
media = _postcssValueParser.default.stringify(nodes).trim().toLowerCase();
|
|
134
|
+
}
|
|
100
135
|
} // eslint-disable-next-line consistent-return
|
|
101
136
|
|
|
102
137
|
|
|
@@ -104,8 +139,11 @@ function parseNode(atRule, key) {
|
|
|
104
139
|
atRule,
|
|
105
140
|
prefix,
|
|
106
141
|
url,
|
|
142
|
+
layer,
|
|
143
|
+
supports,
|
|
107
144
|
media,
|
|
108
|
-
|
|
145
|
+
requestable,
|
|
146
|
+
needResolve
|
|
109
147
|
};
|
|
110
148
|
}
|
|
111
149
|
|
|
@@ -118,10 +156,22 @@ const plugin = (options = {}) => {
|
|
|
118
156
|
return {
|
|
119
157
|
AtRule: {
|
|
120
158
|
import(atRule) {
|
|
159
|
+
if (options.isCSSStyleSheet) {
|
|
160
|
+
options.loaderContext.emitError(new Error(atRule.error("'@import' rules are not allowed here and will not be processed").message));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const {
|
|
165
|
+
isSupportDataURL,
|
|
166
|
+
isSupportAbsoluteURL
|
|
167
|
+
} = options;
|
|
121
168
|
let parsedAtRule;
|
|
122
169
|
|
|
123
170
|
try {
|
|
124
|
-
parsedAtRule = parseNode(atRule, "params",
|
|
171
|
+
parsedAtRule = parseNode(atRule, "params", {
|
|
172
|
+
isSupportAbsoluteURL,
|
|
173
|
+
isSupportDataURL
|
|
174
|
+
});
|
|
125
175
|
} catch (error) {
|
|
126
176
|
result.warn(error.message, {
|
|
127
177
|
node: error.node
|
|
@@ -142,36 +192,46 @@ const plugin = (options = {}) => {
|
|
|
142
192
|
return;
|
|
143
193
|
}
|
|
144
194
|
|
|
195
|
+
const {
|
|
196
|
+
loaderContext
|
|
197
|
+
} = options;
|
|
198
|
+
const resolver = loaderContext.getResolve({
|
|
199
|
+
dependencyType: "css",
|
|
200
|
+
conditionNames: ["style"],
|
|
201
|
+
mainFields: ["css", "style", "main", "..."],
|
|
202
|
+
mainFiles: ["index", "..."],
|
|
203
|
+
extensions: [".css", "..."],
|
|
204
|
+
preferRelative: true
|
|
205
|
+
});
|
|
145
206
|
const resolvedAtRules = await Promise.all(parsedAtRules.map(async parsedAtRule => {
|
|
146
207
|
const {
|
|
147
208
|
atRule,
|
|
148
|
-
|
|
209
|
+
requestable,
|
|
210
|
+
needResolve,
|
|
149
211
|
prefix,
|
|
150
212
|
url,
|
|
213
|
+
layer,
|
|
214
|
+
supports,
|
|
151
215
|
media
|
|
152
216
|
} = parsedAtRule;
|
|
153
217
|
|
|
154
218
|
if (options.filter) {
|
|
155
|
-
const needKeep = await options.filter(url, media);
|
|
219
|
+
const needKeep = await options.filter(url, media, loaderContext.resourcePath, supports, layer);
|
|
156
220
|
|
|
157
221
|
if (!needKeep) {
|
|
158
222
|
return;
|
|
159
223
|
}
|
|
160
224
|
}
|
|
161
225
|
|
|
162
|
-
if (
|
|
163
|
-
const request = (0, _utils.requestify)(url,
|
|
164
|
-
const
|
|
165
|
-
resolver,
|
|
166
|
-
context
|
|
167
|
-
} = options;
|
|
168
|
-
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, url])]);
|
|
226
|
+
if (needResolve) {
|
|
227
|
+
const request = (0, _utils.requestify)(url, loaderContext.rootContext);
|
|
228
|
+
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, loaderContext.context, [...new Set([request, url])]);
|
|
169
229
|
|
|
170
230
|
if (!resolvedUrl) {
|
|
171
231
|
return;
|
|
172
232
|
}
|
|
173
233
|
|
|
174
|
-
if (resolvedUrl ===
|
|
234
|
+
if (resolvedUrl === loaderContext.resourcePath) {
|
|
175
235
|
atRule.remove();
|
|
176
236
|
return;
|
|
177
237
|
}
|
|
@@ -180,9 +240,11 @@ const plugin = (options = {}) => {
|
|
|
180
240
|
|
|
181
241
|
return {
|
|
182
242
|
url: resolvedUrl,
|
|
243
|
+
layer,
|
|
244
|
+
supports,
|
|
183
245
|
media,
|
|
184
246
|
prefix,
|
|
185
|
-
|
|
247
|
+
requestable
|
|
186
248
|
};
|
|
187
249
|
}
|
|
188
250
|
|
|
@@ -190,9 +252,11 @@ const plugin = (options = {}) => {
|
|
|
190
252
|
|
|
191
253
|
return {
|
|
192
254
|
url,
|
|
255
|
+
layer,
|
|
256
|
+
supports,
|
|
193
257
|
media,
|
|
194
258
|
prefix,
|
|
195
|
-
|
|
259
|
+
requestable
|
|
196
260
|
};
|
|
197
261
|
}));
|
|
198
262
|
const urlToNameMap = new Map();
|
|
@@ -207,13 +271,17 @@ const plugin = (options = {}) => {
|
|
|
207
271
|
|
|
208
272
|
const {
|
|
209
273
|
url,
|
|
210
|
-
|
|
274
|
+
requestable,
|
|
275
|
+
layer,
|
|
276
|
+
supports,
|
|
211
277
|
media
|
|
212
278
|
} = resolvedAtRule;
|
|
213
279
|
|
|
214
|
-
if (!
|
|
280
|
+
if (!requestable) {
|
|
215
281
|
options.api.push({
|
|
216
282
|
url,
|
|
283
|
+
layer,
|
|
284
|
+
supports,
|
|
217
285
|
media,
|
|
218
286
|
index
|
|
219
287
|
}); // eslint-disable-next-line no-continue
|
|
@@ -240,6 +308,8 @@ const plugin = (options = {}) => {
|
|
|
240
308
|
|
|
241
309
|
options.api.push({
|
|
242
310
|
importName,
|
|
311
|
+
layer,
|
|
312
|
+
supports,
|
|
243
313
|
media,
|
|
244
314
|
index
|
|
245
315
|
});
|
|
@@ -49,32 +49,21 @@ function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
|
|
|
49
49
|
return matched && matched[2] === "true";
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function shouldHandleURL(url, declaration, result,
|
|
52
|
+
function shouldHandleURL(url, declaration, result, options) {
|
|
53
53
|
if (url.length === 0) {
|
|
54
54
|
result.warn(`Unable to find uri in '${declaration.toString()}'`, {
|
|
55
55
|
node: declaration
|
|
56
56
|
});
|
|
57
|
-
return
|
|
57
|
+
return {
|
|
58
|
+
requestable: false,
|
|
59
|
+
needResolve: false
|
|
60
|
+
};
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
decodeURIComponent(url);
|
|
63
|
-
} catch (ignoreError) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!(0, _utils.isUrlRequestable)(url)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return true;
|
|
63
|
+
return (0, _utils.isURLRequestable)(url, options);
|
|
75
64
|
}
|
|
76
65
|
|
|
77
|
-
function parseDeclaration(declaration, key, result,
|
|
66
|
+
function parseDeclaration(declaration, key, result, options) {
|
|
78
67
|
if (!needParseDeclaration.test(declaration[key])) {
|
|
79
68
|
return;
|
|
80
69
|
}
|
|
@@ -126,9 +115,13 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
126
115
|
} = valueNode;
|
|
127
116
|
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
|
|
128
117
|
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
|
129
|
-
url = (0, _utils.normalizeUrl)(url, isStringValue);
|
|
118
|
+
url = (0, _utils.normalizeUrl)(url, isStringValue);
|
|
119
|
+
const {
|
|
120
|
+
requestable,
|
|
121
|
+
needResolve
|
|
122
|
+
} = shouldHandleURL(url, declaration, result, options); // Do not traverse inside `url`
|
|
130
123
|
|
|
131
|
-
if (!
|
|
124
|
+
if (!requestable) {
|
|
132
125
|
// eslint-disable-next-line consistent-return
|
|
133
126
|
return false;
|
|
134
127
|
}
|
|
@@ -147,7 +140,8 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
147
140
|
node: getNodeFromUrlFunc(valueNode),
|
|
148
141
|
prefix,
|
|
149
142
|
url,
|
|
150
|
-
needQuotes: false
|
|
143
|
+
needQuotes: false,
|
|
144
|
+
needResolve
|
|
151
145
|
}); // eslint-disable-next-line consistent-return
|
|
152
146
|
|
|
153
147
|
return false;
|
|
@@ -176,9 +170,13 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
176
170
|
} = nNode;
|
|
177
171
|
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
|
|
178
172
|
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
|
179
|
-
url = (0, _utils.normalizeUrl)(url, isStringValue);
|
|
173
|
+
url = (0, _utils.normalizeUrl)(url, isStringValue);
|
|
174
|
+
const {
|
|
175
|
+
requestable,
|
|
176
|
+
needResolve
|
|
177
|
+
} = shouldHandleURL(url, declaration, result, options); // Do not traverse inside `url`
|
|
180
178
|
|
|
181
|
-
if (!
|
|
179
|
+
if (!requestable) {
|
|
182
180
|
// eslint-disable-next-line consistent-return
|
|
183
181
|
return false;
|
|
184
182
|
}
|
|
@@ -197,7 +195,8 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
197
195
|
node: getNodeFromUrlFunc(nNode),
|
|
198
196
|
prefix,
|
|
199
197
|
url,
|
|
200
|
-
needQuotes: false
|
|
198
|
+
needQuotes: false,
|
|
199
|
+
needResolve
|
|
201
200
|
});
|
|
202
201
|
} else if (type === "string") {
|
|
203
202
|
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
|
|
@@ -212,9 +211,13 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
212
211
|
continue;
|
|
213
212
|
}
|
|
214
213
|
|
|
215
|
-
let url = (0, _utils.normalizeUrl)(value, true);
|
|
214
|
+
let url = (0, _utils.normalizeUrl)(value, true);
|
|
215
|
+
const {
|
|
216
|
+
requestable,
|
|
217
|
+
needResolve
|
|
218
|
+
} = shouldHandleURL(url, declaration, result, options); // Do not traverse inside `url`
|
|
216
219
|
|
|
217
|
-
if (!
|
|
220
|
+
if (!requestable) {
|
|
218
221
|
// eslint-disable-next-line consistent-return
|
|
219
222
|
return false;
|
|
220
223
|
}
|
|
@@ -233,7 +236,8 @@ function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
|
|
233
236
|
node: nNode,
|
|
234
237
|
prefix,
|
|
235
238
|
url,
|
|
236
|
-
needQuotes: true
|
|
239
|
+
needQuotes: true,
|
|
240
|
+
needResolve
|
|
237
241
|
});
|
|
238
242
|
}
|
|
239
243
|
} // Do not traverse inside `image-set`
|
|
@@ -256,9 +260,13 @@ const plugin = (options = {}) => {
|
|
|
256
260
|
return {
|
|
257
261
|
Declaration(declaration) {
|
|
258
262
|
const {
|
|
259
|
-
|
|
263
|
+
isSupportDataURL,
|
|
264
|
+
isSupportAbsoluteURL
|
|
260
265
|
} = options;
|
|
261
|
-
const parsedURL = parseDeclaration(declaration, "value", result,
|
|
266
|
+
const parsedURL = parseDeclaration(declaration, "value", result, {
|
|
267
|
+
isSupportDataURL,
|
|
268
|
+
isSupportAbsoluteURL
|
|
269
|
+
});
|
|
262
270
|
|
|
263
271
|
if (!parsedURL) {
|
|
264
272
|
return;
|
|
@@ -274,7 +282,8 @@ const plugin = (options = {}) => {
|
|
|
274
282
|
|
|
275
283
|
const resolvedDeclarations = await Promise.all(parsedDeclarations.map(async parsedDeclaration => {
|
|
276
284
|
const {
|
|
277
|
-
url
|
|
285
|
+
url,
|
|
286
|
+
needResolve
|
|
278
287
|
} = parsedDeclaration;
|
|
279
288
|
|
|
280
289
|
if (options.filter) {
|
|
@@ -286,7 +295,7 @@ const plugin = (options = {}) => {
|
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
297
|
|
|
289
|
-
if (
|
|
298
|
+
if (!needResolve) {
|
|
290
299
|
// eslint-disable-next-line consistent-return
|
|
291
300
|
return parsedDeclaration;
|
|
292
301
|
}
|
|
@@ -296,12 +305,12 @@ const plugin = (options = {}) => {
|
|
|
296
305
|
let hash = query ? "?" : "";
|
|
297
306
|
hash += hashOrQuery ? `#${hashOrQuery}` : "";
|
|
298
307
|
const {
|
|
299
|
-
|
|
308
|
+
resolver,
|
|
300
309
|
rootContext
|
|
301
310
|
} = options;
|
|
302
|
-
const request = (0, _utils.requestify)(pathname, rootContext,
|
|
311
|
+
const request = (0, _utils.requestify)(pathname, rootContext, Boolean(resolver));
|
|
303
312
|
|
|
304
|
-
if (!
|
|
313
|
+
if (!resolver) {
|
|
305
314
|
// eslint-disable-next-line consistent-return
|
|
306
315
|
return { ...parsedDeclaration,
|
|
307
316
|
url: request,
|
|
@@ -309,20 +318,16 @@ const plugin = (options = {}) => {
|
|
|
309
318
|
};
|
|
310
319
|
}
|
|
311
320
|
|
|
312
|
-
const
|
|
313
|
-
resolver,
|
|
314
|
-
context
|
|
315
|
-
} = options;
|
|
316
|
-
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, url])]);
|
|
321
|
+
const resolvedURL = await (0, _utils.resolveRequests)(resolver, options.context, [...new Set([request, url])]);
|
|
317
322
|
|
|
318
|
-
if (!
|
|
323
|
+
if (!resolvedURL) {
|
|
319
324
|
// eslint-disable-next-line consistent-return
|
|
320
325
|
return;
|
|
321
326
|
} // eslint-disable-next-line consistent-return
|
|
322
327
|
|
|
323
328
|
|
|
324
329
|
return { ...parsedDeclaration,
|
|
325
|
-
url:
|
|
330
|
+
url: resolvedURL,
|
|
326
331
|
hash
|
|
327
332
|
};
|
|
328
333
|
}));
|
|
@@ -361,7 +366,7 @@ const plugin = (options = {}) => {
|
|
|
361
366
|
options.imports.push({
|
|
362
367
|
type: "url",
|
|
363
368
|
importName,
|
|
364
|
-
url: options.
|
|
369
|
+
url: options.resolver ? options.urlHandler(newUrl) : JSON.stringify(newUrl),
|
|
365
370
|
index
|
|
366
371
|
});
|
|
367
372
|
}
|
package/dist/runtime/api.js
CHANGED
|
@@ -4,37 +4,55 @@
|
|
|
4
4
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
5
5
|
Author Tobias Koppers @sokra
|
|
6
6
|
*/
|
|
7
|
-
// css base code, injected by the css-loader
|
|
8
|
-
// eslint-disable-next-line func-names
|
|
9
7
|
module.exports = function (cssWithMappingToString) {
|
|
10
8
|
var list = []; // return the list of modules as css string
|
|
11
9
|
|
|
12
10
|
list.toString = function toString() {
|
|
13
11
|
return this.map(function (item) {
|
|
14
|
-
var content =
|
|
12
|
+
var content = "";
|
|
13
|
+
var needLayer = typeof item[5] !== "undefined";
|
|
14
|
+
|
|
15
|
+
if (item[4]) {
|
|
16
|
+
content += "@supports (".concat(item[4], ") {");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (item[2]) {
|
|
20
|
+
content += "@media ".concat(item[2], " {");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (needLayer) {
|
|
24
|
+
content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
content += cssWithMappingToString(item);
|
|
28
|
+
|
|
29
|
+
if (needLayer) {
|
|
30
|
+
content += "}";
|
|
31
|
+
}
|
|
15
32
|
|
|
16
33
|
if (item[2]) {
|
|
17
|
-
|
|
34
|
+
content += "}";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (item[4]) {
|
|
38
|
+
content += "}";
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
return content;
|
|
21
42
|
}).join("");
|
|
22
43
|
}; // import a list of modules into the list
|
|
23
|
-
// eslint-disable-next-line func-names
|
|
24
44
|
|
|
25
45
|
|
|
26
|
-
list.i = function (modules,
|
|
46
|
+
list.i = function i(modules, media, dedupe, supports, layer) {
|
|
27
47
|
if (typeof modules === "string") {
|
|
28
|
-
|
|
29
|
-
modules = [[null, modules, ""]];
|
|
48
|
+
modules = [[null, modules, undefined]];
|
|
30
49
|
}
|
|
31
50
|
|
|
32
51
|
var alreadyImportedModules = {};
|
|
33
52
|
|
|
34
53
|
if (dedupe) {
|
|
35
|
-
for (var
|
|
36
|
-
|
|
37
|
-
var id = this[i][0];
|
|
54
|
+
for (var k = 0; k < this.length; k++) {
|
|
55
|
+
var id = this[k][0];
|
|
38
56
|
|
|
39
57
|
if (id != null) {
|
|
40
58
|
alreadyImportedModules[id] = true;
|
|
@@ -42,19 +60,37 @@ module.exports = function (cssWithMappingToString) {
|
|
|
42
60
|
}
|
|
43
61
|
}
|
|
44
62
|
|
|
45
|
-
for (var
|
|
46
|
-
var item = [].concat(modules[
|
|
63
|
+
for (var _k = 0; _k < modules.length; _k++) {
|
|
64
|
+
var item = [].concat(modules[_k]);
|
|
47
65
|
|
|
48
66
|
if (dedupe && alreadyImportedModules[item[0]]) {
|
|
49
|
-
// eslint-disable-next-line no-continue
|
|
50
67
|
continue;
|
|
51
68
|
}
|
|
52
69
|
|
|
53
|
-
if (
|
|
70
|
+
if (typeof layer !== "undefined") {
|
|
71
|
+
if (typeof item[5] === "undefined") {
|
|
72
|
+
item[5] = layer;
|
|
73
|
+
} else {
|
|
74
|
+
item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
|
|
75
|
+
item[5] = layer;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (media) {
|
|
54
80
|
if (!item[2]) {
|
|
55
|
-
item[2] =
|
|
81
|
+
item[2] = media;
|
|
82
|
+
} else {
|
|
83
|
+
item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
|
|
84
|
+
item[2] = media;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (supports) {
|
|
89
|
+
if (!item[4]) {
|
|
90
|
+
item[4] = "".concat(supports);
|
|
56
91
|
} else {
|
|
57
|
-
item[
|
|
92
|
+
item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
|
|
93
|
+
item[4] = supports;
|
|
58
94
|
}
|
|
59
95
|
}
|
|
60
96
|
|
package/dist/runtime/getUrl.js
CHANGED
|
@@ -2,24 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = function (url, options) {
|
|
4
4
|
if (!options) {
|
|
5
|
-
// eslint-disable-next-line no-param-reassign
|
|
6
5
|
options = {};
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
if (!url) {
|
|
10
9
|
return url;
|
|
11
|
-
}
|
|
12
|
-
|
|
10
|
+
}
|
|
13
11
|
|
|
14
12
|
url = String(url.__esModule ? url.default : url); // If url is already wrapped in quotes, remove them
|
|
15
13
|
|
|
16
14
|
if (/^['"].*['"]$/.test(url)) {
|
|
17
|
-
// eslint-disable-next-line no-param-reassign
|
|
18
15
|
url = url.slice(1, -1);
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
if (options.hash) {
|
|
22
|
-
// eslint-disable-next-line no-param-reassign
|
|
23
19
|
url += options.hash;
|
|
24
20
|
} // Should url be wrapped?
|
|
25
21
|
// See https://drafts.csswg.org/css-values-3/#urls
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = function (item) {
|
|
4
|
+
var content = item[1];
|
|
5
|
+
var cssMapping = item[3];
|
|
6
|
+
|
|
7
|
+
if (!cssMapping) {
|
|
8
|
+
return content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (typeof btoa === "function") {
|
|
12
|
+
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
|
|
13
|
+
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
|
14
|
+
var sourceMapping = "/*# ".concat(data, " */");
|
|
15
|
+
var sourceURLs = cssMapping.sources.map(function (source) {
|
|
16
|
+
return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
|
|
17
|
+
});
|
|
18
|
+
return [content].concat(sourceURLs).concat([sourceMapping]).join("\n");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [content].join("\n");
|
|
22
|
+
};
|