css-loader 4.3.0 → 5.1.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 +41 -0
- package/README.md +177 -89
- package/dist/CssSyntaxError.js +5 -3
- package/dist/Warning.js +2 -2
- package/dist/cjs.js +1 -1
- package/dist/index.js +25 -17
- package/dist/options.json +0 -4
- package/dist/plugins/postcss-icss-parser.js +101 -96
- package/dist/plugins/postcss-import-parser.js +201 -176
- package/dist/plugins/postcss-url-parser.js +283 -191
- package/dist/runtime/api.js +6 -34
- package/dist/runtime/cssWithMappingToString.js +32 -0
- package/dist/runtime/getUrl.js +2 -2
- package/dist/utils.js +128 -95
- package/package.json +36 -36
|
@@ -5,30 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _util = require("util");
|
|
9
|
-
|
|
10
|
-
var _postcss = _interopRequireDefault(require("postcss"));
|
|
11
|
-
|
|
12
8
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
13
9
|
|
|
14
10
|
var _utils = require("../utils");
|
|
15
11
|
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
13
|
|
|
18
|
-
const pluginName = 'postcss-url-parser';
|
|
19
14
|
const isUrlFunc = /url/i;
|
|
20
15
|
const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
|
|
21
|
-
const
|
|
16
|
+
const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i;
|
|
22
17
|
|
|
23
18
|
function getNodeFromUrlFunc(node) {
|
|
24
19
|
return node.nodes && node.nodes[0];
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
function shouldHandleRule(rule,
|
|
22
|
+
function shouldHandleRule(rule, node, result) {
|
|
28
23
|
// https://www.w3.org/TR/css-syntax-3/#typedef-url-token
|
|
29
|
-
if (rule.url.replace(/^[\s]+|[\s]+$/g,
|
|
30
|
-
result.warn(`Unable to find uri in '${
|
|
31
|
-
node
|
|
24
|
+
if (rule.url.replace(/^[\s]+|[\s]+$/g, "").length === 0) {
|
|
25
|
+
result.warn(`Unable to find uri in '${node.toString()}'`, {
|
|
26
|
+
node
|
|
32
27
|
});
|
|
33
28
|
return false;
|
|
34
29
|
}
|
|
@@ -40,218 +35,315 @@ function shouldHandleRule(rule, decl, result) {
|
|
|
40
35
|
return true;
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
|
|
39
|
+
if (index === 0 && typeof inBetween !== "undefined") {
|
|
40
|
+
return inBetween;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let prevValueNode = nodes[index - 1];
|
|
44
|
+
|
|
45
|
+
if (!prevValueNode) {
|
|
46
|
+
// eslint-disable-next-line consistent-return
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (prevValueNode.type === "space") {
|
|
51
|
+
if (!nodes[index - 2]) {
|
|
52
|
+
// eslint-disable-next-line consistent-return
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
prevValueNode = nodes[index - 2];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (prevValueNode.type !== "comment") {
|
|
60
|
+
// eslint-disable-next-line consistent-return
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const matched = prevValueNode.value.match(_utils.webpackIgnoreCommentRegexp);
|
|
65
|
+
return matched && matched[2] === "true";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function visitor(result, parsedResults, node, key) {
|
|
69
|
+
if (!needParseDeclaration.test(node[key])) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const parsed = (0, _postcssValueParser.default)(typeof node.raws.value === "undefined" ? node[key] : node.raws.value.raw);
|
|
74
|
+
let inBetween;
|
|
75
|
+
|
|
76
|
+
if (typeof node.raws.between !== "undefined") {
|
|
77
|
+
const lastCommentIndex = node.raws.between.lastIndexOf("/*");
|
|
78
|
+
const matched = node.raws.between.slice(lastCommentIndex).match(_utils.webpackIgnoreCommentRegexp);
|
|
79
|
+
|
|
80
|
+
if (matched) {
|
|
81
|
+
inBetween = matched[2] === "true";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let isIgnoreOnDeclaration = false;
|
|
86
|
+
const prevNode = node.prev();
|
|
87
|
+
|
|
88
|
+
if (prevNode && prevNode.type === "comment") {
|
|
89
|
+
const matched = prevNode.text.match(_utils.webpackIgnoreCommentRegexp);
|
|
90
|
+
|
|
91
|
+
if (matched) {
|
|
92
|
+
isIgnoreOnDeclaration = matched[2] === "true";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let needIgnore;
|
|
97
|
+
parsed.walk((valueNode, index, valueNodes) => {
|
|
98
|
+
if (valueNode.type !== "function") {
|
|
47
99
|
return;
|
|
48
100
|
}
|
|
49
101
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
102
|
+
if (isUrlFunc.test(valueNode.value)) {
|
|
103
|
+
needIgnore = getWebpackIgnoreCommentValue(index, valueNodes, inBetween);
|
|
104
|
+
|
|
105
|
+
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
|
|
106
|
+
if (needIgnore) {
|
|
107
|
+
// eslint-disable-next-line no-undefined
|
|
108
|
+
needIgnore = undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
53
111
|
return;
|
|
54
112
|
}
|
|
55
113
|
|
|
56
|
-
|
|
114
|
+
const {
|
|
115
|
+
nodes
|
|
116
|
+
} = valueNode;
|
|
117
|
+
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
|
|
118
|
+
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
|
119
|
+
const rule = {
|
|
120
|
+
node: getNodeFromUrlFunc(valueNode),
|
|
121
|
+
url,
|
|
122
|
+
needQuotes: false,
|
|
123
|
+
isStringValue
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
if (shouldHandleRule(rule, node, result)) {
|
|
127
|
+
parsedResults.push({
|
|
128
|
+
node,
|
|
129
|
+
rule,
|
|
130
|
+
parsed
|
|
131
|
+
});
|
|
132
|
+
} // Do not traverse inside `url`
|
|
133
|
+
// eslint-disable-next-line consistent-return
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
return false;
|
|
137
|
+
} else if (isImageSetFunc.test(valueNode.value)) {
|
|
138
|
+
for (const [innerIndex, nNode] of valueNode.nodes.entries()) {
|
|
57
139
|
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} // Do not traverse inside `url`
|
|
76
|
-
// eslint-disable-next-line consistent-return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return false;
|
|
80
|
-
} else if (isImageSetFunc.test(node.value)) {
|
|
81
|
-
for (const nNode of node.nodes) {
|
|
140
|
+
type,
|
|
141
|
+
value
|
|
142
|
+
} = nNode;
|
|
143
|
+
|
|
144
|
+
if (type === "function" && isUrlFunc.test(value)) {
|
|
145
|
+
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
|
|
146
|
+
|
|
147
|
+
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
|
|
148
|
+
if (needIgnore) {
|
|
149
|
+
// eslint-disable-next-line no-undefined
|
|
150
|
+
needIgnore = undefined;
|
|
151
|
+
} // eslint-disable-next-line no-continue
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
82
157
|
const {
|
|
83
|
-
|
|
84
|
-
value
|
|
158
|
+
nodes
|
|
85
159
|
} = nNode;
|
|
160
|
+
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
|
|
161
|
+
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
|
162
|
+
const rule = {
|
|
163
|
+
node: getNodeFromUrlFunc(nNode),
|
|
164
|
+
url,
|
|
165
|
+
needQuotes: false,
|
|
166
|
+
isStringValue
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
if (shouldHandleRule(rule, node, result)) {
|
|
170
|
+
parsedResults.push({
|
|
171
|
+
node,
|
|
172
|
+
rule,
|
|
173
|
+
parsed
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
} else if (type === "string") {
|
|
177
|
+
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
|
|
86
178
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
|
|
93
|
-
const rule = {
|
|
94
|
-
node: getNodeFromUrlFunc(nNode),
|
|
95
|
-
url,
|
|
96
|
-
needQuotes: false,
|
|
97
|
-
isStringValue
|
|
98
|
-
};
|
|
179
|
+
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
|
|
180
|
+
if (needIgnore) {
|
|
181
|
+
// eslint-disable-next-line no-undefined
|
|
182
|
+
needIgnore = undefined;
|
|
183
|
+
} // eslint-disable-next-line no-continue
|
|
99
184
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
decl,
|
|
103
|
-
rule,
|
|
104
|
-
parsed
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
} else if (type === 'string') {
|
|
108
|
-
const rule = {
|
|
109
|
-
node: nNode,
|
|
110
|
-
url: value,
|
|
111
|
-
needQuotes: true,
|
|
112
|
-
isStringValue: true
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
if (shouldHandleRule(rule, decl, result)) {
|
|
116
|
-
accumulator.push({
|
|
117
|
-
decl,
|
|
118
|
-
rule,
|
|
119
|
-
parsed
|
|
120
|
-
});
|
|
121
|
-
}
|
|
185
|
+
|
|
186
|
+
continue;
|
|
122
187
|
}
|
|
123
|
-
} // Do not traverse inside `image-set`
|
|
124
|
-
// eslint-disable-next-line consistent-return
|
|
125
188
|
|
|
189
|
+
const rule = {
|
|
190
|
+
node: nNode,
|
|
191
|
+
url: value,
|
|
192
|
+
needQuotes: true,
|
|
193
|
+
isStringValue: true
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
if (shouldHandleRule(rule, node, result)) {
|
|
197
|
+
parsedResults.push({
|
|
198
|
+
node,
|
|
199
|
+
rule,
|
|
200
|
+
parsed
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
} // Do not traverse inside `image-set`
|
|
205
|
+
// eslint-disable-next-line consistent-return
|
|
126
206
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
207
|
+
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
130
210
|
});
|
|
131
|
-
callback(null, accumulator);
|
|
132
211
|
}
|
|
133
212
|
|
|
134
|
-
const
|
|
213
|
+
const plugin = (options = {}) => {
|
|
214
|
+
return {
|
|
215
|
+
postcssPlugin: "postcss-url-parser",
|
|
135
216
|
|
|
136
|
-
|
|
137
|
-
|
|
217
|
+
prepare(result) {
|
|
218
|
+
const parsedResults = [];
|
|
219
|
+
return {
|
|
220
|
+
Declaration(declaration) {
|
|
221
|
+
visitor(result, parsedResults, declaration, "value");
|
|
222
|
+
},
|
|
138
223
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
224
|
+
async OnceExit() {
|
|
225
|
+
if (parsedResults.length === 0) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
142
228
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
for (const parsedResult of parsedResults) {
|
|
149
|
-
const {
|
|
150
|
-
url,
|
|
151
|
-
isStringValue
|
|
152
|
-
} = parsedResult.rule;
|
|
153
|
-
let normalizedUrl = url;
|
|
154
|
-
let prefix = '';
|
|
155
|
-
const queryParts = normalizedUrl.split('!');
|
|
156
|
-
|
|
157
|
-
if (queryParts.length > 1) {
|
|
158
|
-
normalizedUrl = queryParts.pop();
|
|
159
|
-
prefix = queryParts.join('!');
|
|
160
|
-
}
|
|
229
|
+
const tasks = [];
|
|
230
|
+
const imports = new Map();
|
|
231
|
+
const replacements = new Map();
|
|
232
|
+
let hasUrlImportHelper = false;
|
|
161
233
|
|
|
162
|
-
|
|
234
|
+
for (const parsedResult of parsedResults) {
|
|
235
|
+
const {
|
|
236
|
+
url,
|
|
237
|
+
isStringValue
|
|
238
|
+
} = parsedResult.rule;
|
|
239
|
+
let normalizedUrl = url;
|
|
240
|
+
let prefix = "";
|
|
241
|
+
const queryParts = normalizedUrl.split("!");
|
|
242
|
+
|
|
243
|
+
if (queryParts.length > 1) {
|
|
244
|
+
normalizedUrl = queryParts.pop();
|
|
245
|
+
prefix = queryParts.join("!");
|
|
246
|
+
}
|
|
163
247
|
|
|
164
|
-
|
|
165
|
-
// eslint-disable-next-line no-continue
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
248
|
+
normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl, isStringValue);
|
|
168
249
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
index: -1
|
|
174
|
-
});
|
|
175
|
-
hasUrlImportHelper = true;
|
|
176
|
-
}
|
|
250
|
+
if (!options.filter(normalizedUrl)) {
|
|
251
|
+
// eslint-disable-next-line no-continue
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
177
254
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
context
|
|
187
|
-
} = options;
|
|
188
|
-
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, normalizedUrl])]);
|
|
189
|
-
return {
|
|
190
|
-
url: resolvedUrl,
|
|
191
|
-
prefix,
|
|
192
|
-
hash,
|
|
193
|
-
parsedResult
|
|
194
|
-
};
|
|
195
|
-
})());
|
|
196
|
-
}
|
|
255
|
+
if (!hasUrlImportHelper) {
|
|
256
|
+
options.imports.push({
|
|
257
|
+
importName: "___CSS_LOADER_GET_URL_IMPORT___",
|
|
258
|
+
url: options.urlHandler(require.resolve("../runtime/getUrl.js")),
|
|
259
|
+
index: -1
|
|
260
|
+
});
|
|
261
|
+
hasUrlImportHelper = true;
|
|
262
|
+
}
|
|
197
263
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
imports.set(importKey, importName);
|
|
218
|
-
options.imports.push({
|
|
219
|
-
importName,
|
|
220
|
-
url: options.urlHandler(newUrl),
|
|
221
|
-
index
|
|
222
|
-
});
|
|
223
|
-
}
|
|
264
|
+
const splittedUrl = normalizedUrl.split(/(\?)?#/);
|
|
265
|
+
const [pathname, query, hashOrQuery] = splittedUrl;
|
|
266
|
+
let hash = query ? "?" : "";
|
|
267
|
+
hash += hashOrQuery ? `#${hashOrQuery}` : "";
|
|
268
|
+
const request = (0, _utils.requestify)(pathname, options.rootContext);
|
|
269
|
+
tasks.push((async () => {
|
|
270
|
+
const {
|
|
271
|
+
resolver,
|
|
272
|
+
context
|
|
273
|
+
} = options;
|
|
274
|
+
const resolvedUrl = await (0, _utils.resolveRequests)(resolver, context, [...new Set([request, normalizedUrl])]);
|
|
275
|
+
return {
|
|
276
|
+
url: resolvedUrl,
|
|
277
|
+
prefix,
|
|
278
|
+
hash,
|
|
279
|
+
parsedResult
|
|
280
|
+
};
|
|
281
|
+
})());
|
|
282
|
+
}
|
|
224
283
|
|
|
225
|
-
|
|
226
|
-
needQuotes
|
|
227
|
-
} = rule;
|
|
228
|
-
const replacementKey = JSON.stringify({
|
|
229
|
-
newUrl,
|
|
230
|
-
hash,
|
|
231
|
-
needQuotes
|
|
232
|
-
});
|
|
233
|
-
let replacementName = replacements.get(replacementKey);
|
|
284
|
+
const results = await Promise.all(tasks);
|
|
234
285
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
286
|
+
for (let index = 0; index <= results.length - 1; index++) {
|
|
287
|
+
const {
|
|
288
|
+
url,
|
|
289
|
+
prefix,
|
|
290
|
+
hash,
|
|
291
|
+
parsedResult: {
|
|
292
|
+
node,
|
|
293
|
+
rule,
|
|
294
|
+
parsed
|
|
295
|
+
}
|
|
296
|
+
} = results[index];
|
|
297
|
+
const newUrl = prefix ? `${prefix}!${url}` : url;
|
|
298
|
+
const importKey = newUrl;
|
|
299
|
+
let importName = imports.get(importKey);
|
|
300
|
+
|
|
301
|
+
if (!importName) {
|
|
302
|
+
importName = `___CSS_LOADER_URL_IMPORT_${imports.size}___`;
|
|
303
|
+
imports.set(importKey, importName);
|
|
304
|
+
options.imports.push({
|
|
305
|
+
importName,
|
|
306
|
+
url: options.urlHandler(newUrl),
|
|
307
|
+
index
|
|
308
|
+
});
|
|
309
|
+
}
|
|
245
310
|
|
|
311
|
+
const {
|
|
312
|
+
needQuotes
|
|
313
|
+
} = rule;
|
|
314
|
+
const replacementKey = JSON.stringify({
|
|
315
|
+
newUrl,
|
|
316
|
+
hash,
|
|
317
|
+
needQuotes
|
|
318
|
+
});
|
|
319
|
+
let replacementName = replacements.get(replacementKey);
|
|
320
|
+
|
|
321
|
+
if (!replacementName) {
|
|
322
|
+
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${replacements.size}___`;
|
|
323
|
+
replacements.set(replacementKey, replacementName);
|
|
324
|
+
options.replacements.push({
|
|
325
|
+
replacementName,
|
|
326
|
+
importName,
|
|
327
|
+
hash,
|
|
328
|
+
needQuotes
|
|
329
|
+
});
|
|
330
|
+
} // eslint-disable-next-line no-param-reassign
|
|
246
331
|
|
|
247
|
-
rule.node.type = 'word'; // eslint-disable-next-line no-param-reassign
|
|
248
332
|
|
|
249
|
-
|
|
333
|
+
rule.node.type = "word"; // eslint-disable-next-line no-param-reassign
|
|
250
334
|
|
|
251
|
-
|
|
252
|
-
}
|
|
335
|
+
rule.node.value = replacementName; // eslint-disable-next-line no-param-reassign
|
|
253
336
|
|
|
254
|
-
|
|
255
|
-
}
|
|
337
|
+
node.value = parsed.toString();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
};
|
|
345
|
+
};
|
|
256
346
|
|
|
347
|
+
plugin.postcss = true;
|
|
348
|
+
var _default = plugin;
|
|
257
349
|
exports.default = _default;
|
package/dist/runtime/api.js
CHANGED
|
@@ -6,27 +6,27 @@
|
|
|
6
6
|
*/
|
|
7
7
|
// css base code, injected by the css-loader
|
|
8
8
|
// eslint-disable-next-line func-names
|
|
9
|
-
module.exports = function (
|
|
9
|
+
module.exports = function (cssWithMappingToString) {
|
|
10
10
|
var list = []; // return the list of modules as css string
|
|
11
11
|
|
|
12
12
|
list.toString = function toString() {
|
|
13
13
|
return this.map(function (item) {
|
|
14
|
-
var content = cssWithMappingToString(item
|
|
14
|
+
var content = cssWithMappingToString(item);
|
|
15
15
|
|
|
16
16
|
if (item[2]) {
|
|
17
17
|
return "@media ".concat(item[2], " {").concat(content, "}");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return content;
|
|
21
|
-
}).join(
|
|
21
|
+
}).join("");
|
|
22
22
|
}; // import a list of modules into the list
|
|
23
23
|
// eslint-disable-next-line func-names
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
list.i = function (modules, mediaQuery, dedupe) {
|
|
27
|
-
if (typeof modules ===
|
|
27
|
+
if (typeof modules === "string") {
|
|
28
28
|
// eslint-disable-next-line no-param-reassign
|
|
29
|
-
modules = [[null, modules,
|
|
29
|
+
modules = [[null, modules, ""]];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
var alreadyImportedModules = {};
|
|
@@ -63,32 +63,4 @@ module.exports = function (useSourceMap) {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
return list;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
function cssWithMappingToString(item, useSourceMap) {
|
|
69
|
-
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
|
|
70
|
-
|
|
71
|
-
var cssMapping = item[3];
|
|
72
|
-
|
|
73
|
-
if (!cssMapping) {
|
|
74
|
-
return content;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (useSourceMap && typeof btoa === 'function') {
|
|
78
|
-
var sourceMapping = toComment(cssMapping);
|
|
79
|
-
var sourceURLs = cssMapping.sources.map(function (source) {
|
|
80
|
-
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
|
|
81
|
-
});
|
|
82
|
-
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return [content].join('\n');
|
|
86
|
-
} // Adapted from convert-source-map (MIT)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
function toComment(sourceMap) {
|
|
90
|
-
// eslint-disable-next-line no-undef
|
|
91
|
-
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
92
|
-
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
|
93
|
-
return "/*# ".concat(data, " */");
|
|
94
|
-
}
|
|
66
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
|
|
15
|
+
module.exports = function cssWithMappingToString(item) {
|
|
16
|
+
var _item = _slicedToArray(item, 4),
|
|
17
|
+
content = _item[1],
|
|
18
|
+
cssMapping = _item[3];
|
|
19
|
+
|
|
20
|
+
if (typeof btoa === "function") {
|
|
21
|
+
// eslint-disable-next-line no-undef
|
|
22
|
+
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
|
|
23
|
+
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
|
24
|
+
var sourceMapping = "/*# ".concat(data, " */");
|
|
25
|
+
var sourceURLs = cssMapping.sources.map(function (source) {
|
|
26
|
+
return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
|
|
27
|
+
});
|
|
28
|
+
return [content].concat(sourceURLs).concat([sourceMapping]).join("\n");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return [content].join("\n");
|
|
32
|
+
};
|
package/dist/runtime/getUrl.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = function (url, options) {
|
|
|
9
9
|
|
|
10
10
|
url = url && url.__esModule ? url.default : url;
|
|
11
11
|
|
|
12
|
-
if (typeof url !==
|
|
12
|
+
if (typeof url !== "string") {
|
|
13
13
|
return url;
|
|
14
14
|
} // If url is already wrapped in quotes, remove them
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ module.exports = function (url, options) {
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
if (/["'() \t\n]/.test(url) || options.needQuotes) {
|
|
30
|
-
return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g,
|
|
30
|
+
return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return url;
|