css-loader 5.0.1 → 5.0.2

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/dist/index.js CHANGED
@@ -34,8 +34,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
34
  async function loader(content, map, meta) {
35
35
  const rawOptions = (0, _loaderUtils.getOptions)(this);
36
36
  (0, _schemaUtils.validate)(_options.default, rawOptions, {
37
- name: 'CSS Loader',
38
- baseDataPath: 'options'
37
+ name: "CSS Loader",
38
+ baseDataPath: "options"
39
39
  });
40
40
  const plugins = [];
41
41
  const callback = this.async();
@@ -60,10 +60,10 @@ async function loader(content, map, meta) {
60
60
 
61
61
  if ((0, _utils.shouldUseImportPlugin)(options)) {
62
62
  const resolver = this.getResolve({
63
- conditionNames: ['style'],
64
- extensions: ['.css'],
65
- mainFields: ['css', 'style', 'main', '...'],
66
- mainFiles: ['index', '...'],
63
+ conditionNames: ["style"],
64
+ extensions: [".css"],
65
+ mainFields: ["css", "style", "main", "..."],
66
+ mainFiles: ["index", "..."],
67
67
  restrictions: [/\.css$/i]
68
68
  });
69
69
  plugins.push((0, _plugins.importParser)({
@@ -81,8 +81,8 @@ async function loader(content, map, meta) {
81
81
 
82
82
  if ((0, _utils.shouldUseURLPlugin)(options)) {
83
83
  const urlResolver = this.getResolve({
84
- conditionNames: ['asset'],
85
- mainFields: ['asset'],
84
+ conditionNames: ["asset"],
85
+ mainFields: ["asset"],
86
86
  mainFiles: [],
87
87
  extensions: []
88
88
  });
@@ -102,10 +102,10 @@ async function loader(content, map, meta) {
102
102
 
103
103
  if ((0, _utils.shouldUseIcssPlugin)(options)) {
104
104
  const icssResolver = this.getResolve({
105
- conditionNames: ['style'],
105
+ conditionNames: ["style"],
106
106
  extensions: [],
107
- mainFields: ['css', 'style', 'main', '...'],
108
- mainFiles: ['index', '...']
107
+ mainFields: ["css", "style", "main", "..."],
108
+ mainFiles: ["index", "..."]
109
109
  });
110
110
  plugins.push((0, _plugins.icssParser)({
111
111
  imports: icssPluginImports,
@@ -125,7 +125,7 @@ async function loader(content, map, meta) {
125
125
  ast
126
126
  } = meta;
127
127
 
128
- if (ast && ast.type === 'postcss' && (0, _semver.satisfies)(ast.version, `^${_package.default.version}`)) {
128
+ if (ast && ast.type === "postcss" && (0, _semver.satisfies)(ast.version, `^${_package.default.version}`)) {
129
129
  // eslint-disable-next-line no-param-reassign
130
130
  content = ast.root;
131
131
  }
@@ -152,7 +152,7 @@ async function loader(content, map, meta) {
152
152
  this.addDependency(error.file);
153
153
  }
154
154
 
155
- callback(error.name === 'CssSyntaxError' ? new _CssSyntaxError.default(error) : error);
155
+ callback(error.name === "CssSyntaxError" ? new _CssSyntaxError.default(error) : error);
156
156
  return;
157
157
  }
158
158
 
@@ -165,14 +165,14 @@ async function loader(content, map, meta) {
165
165
 
166
166
  if (options.modules.exportOnlyLocals !== true) {
167
167
  imports.unshift({
168
- importName: '___CSS_LOADER_API_IMPORT___',
169
- url: (0, _loaderUtils.stringifyRequest)(this, require.resolve('./runtime/api'))
168
+ importName: "___CSS_LOADER_API_IMPORT___",
169
+ url: (0, _loaderUtils.stringifyRequest)(this, require.resolve("./runtime/api"))
170
170
  });
171
171
 
172
172
  if (options.sourceMap) {
173
173
  imports.unshift({
174
- importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___',
175
- url: (0, _loaderUtils.stringifyRequest)(this, require.resolve('./runtime/cssWithMappingToString'))
174
+ importName: "___CSS_LOADER_API_SOURCEMAP_IMPORT___",
175
+ url: (0, _loaderUtils.stringifyRequest)(this, require.resolve("./runtime/cssWithMappingToString"))
176
176
  });
177
177
  }
178
178
  }
@@ -11,7 +11,7 @@ var _utils = require("../utils");
11
11
 
12
12
  const plugin = (options = {}) => {
13
13
  return {
14
- postcssPlugin: 'postcss-icss-parser',
14
+ postcssPlugin: "postcss-icss-parser",
15
15
 
16
16
  async OnceExit(root) {
17
17
  const importReplacements = Object.create(null);
@@ -31,12 +31,12 @@ const plugin = (options = {}) => {
31
31
  }
32
32
 
33
33
  let normalizedUrl = url;
34
- let prefix = '';
35
- const queryParts = normalizedUrl.split('!');
34
+ let prefix = "";
35
+ const queryParts = normalizedUrl.split("!");
36
36
 
37
37
  if (queryParts.length > 1) {
38
38
  normalizedUrl = queryParts.pop();
39
- prefix = queryParts.join('!');
39
+ prefix = queryParts.join("!");
40
40
  }
41
41
 
42
42
  const request = (0, _utils.requestify)((0, _utils.normalizeUrl)(normalizedUrl, true), options.rootContext);
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
 
14
14
  function visitor(result, parsedResults, node, key) {
15
15
  // Convert only top-level @import
16
- if (node.parent.type !== 'root') {
16
+ if (node.parent.type !== "root") {
17
17
  return;
18
18
  } // Nodes do not exists - `@import url('http://') :root {}`
19
19
 
@@ -30,7 +30,7 @@ function visitor(result, parsedResults, node, key) {
30
30
  } = (0, _postcssValueParser.default)(node[key]); // No nodes - `@import ;`
31
31
  // Invalid type - `@import foo-bar;`
32
32
 
33
- if (paramsNodes.length === 0 || paramsNodes[0].type !== 'string' && paramsNodes[0].type !== 'function') {
33
+ if (paramsNodes.length === 0 || paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function") {
34
34
  result.warn(`Unable to find uri in "${node.toString()}"`, {
35
35
  node
36
36
  });
@@ -40,19 +40,19 @@ function visitor(result, parsedResults, node, key) {
40
40
  let isStringValue;
41
41
  let url;
42
42
 
43
- if (paramsNodes[0].type === 'string') {
43
+ if (paramsNodes[0].type === "string") {
44
44
  isStringValue = true;
45
45
  url = paramsNodes[0].value;
46
46
  } else {
47
47
  // Invalid function - `@import nourl(test.css);`
48
- if (paramsNodes[0].value.toLowerCase() !== 'url') {
48
+ if (paramsNodes[0].value.toLowerCase() !== "url") {
49
49
  result.warn(`Unable to find uri in "${node.toString()}"`, {
50
50
  node
51
51
  });
52
52
  return;
53
53
  }
54
54
 
55
- isStringValue = paramsNodes[0].nodes.length !== 0 && paramsNodes[0].nodes[0].type === 'string';
55
+ isStringValue = paramsNodes[0].nodes.length !== 0 && paramsNodes[0].nodes[0].type === "string";
56
56
  url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
57
57
  } // Empty url - `@import "";` or `@import url();`
58
58
 
@@ -74,14 +74,14 @@ function visitor(result, parsedResults, node, key) {
74
74
 
75
75
  const plugin = (options = {}) => {
76
76
  return {
77
- postcssPlugin: 'postcss-import-parser',
77
+ postcssPlugin: "postcss-import-parser",
78
78
 
79
79
  prepare(result) {
80
80
  const parsedResults = [];
81
81
  return {
82
82
  AtRule: {
83
83
  import(atRule) {
84
- visitor(result, parsedResults, atRule, 'params');
84
+ visitor(result, parsedResults, atRule, "params");
85
85
  }
86
86
 
87
87
  },
@@ -102,15 +102,15 @@ const plugin = (options = {}) => {
102
102
  mediaNodes
103
103
  } = parsedResult;
104
104
  let normalizedUrl = url;
105
- let prefix = '';
105
+ let prefix = "";
106
106
  const isRequestable = (0, _utils.isUrlRequestable)(normalizedUrl);
107
107
 
108
108
  if (isRequestable) {
109
- const queryParts = normalizedUrl.split('!');
109
+ const queryParts = normalizedUrl.split("!");
110
110
 
111
111
  if (queryParts.length > 1) {
112
112
  normalizedUrl = queryParts.pop();
113
- prefix = queryParts.join('!');
113
+ prefix = queryParts.join("!");
114
114
  }
115
115
 
116
116
  normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl, isStringValue); // Empty url after normalize - `@import '\
@@ -21,7 +21,7 @@ function getNodeFromUrlFunc(node) {
21
21
 
22
22
  function shouldHandleRule(rule, node, result) {
23
23
  // https://www.w3.org/TR/css-syntax-3/#typedef-url-token
24
- if (rule.url.replace(/^[\s]+|[\s]+$/g, '').length === 0) {
24
+ if (rule.url.replace(/^[\s]+|[\s]+$/g, "").length === 0) {
25
25
  result.warn(`Unable to find uri in '${node.toString()}'`, {
26
26
  node
27
27
  });
@@ -42,7 +42,7 @@ function visitor(result, parsedResults, node, key) {
42
42
 
43
43
  const parsed = (0, _postcssValueParser.default)(node[key]);
44
44
  parsed.walk(valueNode => {
45
- if (valueNode.type !== 'function') {
45
+ if (valueNode.type !== "function") {
46
46
  return;
47
47
  }
48
48
 
@@ -50,7 +50,7 @@ function visitor(result, parsedResults, node, key) {
50
50
  const {
51
51
  nodes
52
52
  } = valueNode;
53
- const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
53
+ const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
54
54
  const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
55
55
  const rule = {
56
56
  node: getNodeFromUrlFunc(valueNode),
@@ -77,11 +77,11 @@ function visitor(result, parsedResults, node, key) {
77
77
  value
78
78
  } = nNode;
79
79
 
80
- if (type === 'function' && isUrlFunc.test(value)) {
80
+ if (type === "function" && isUrlFunc.test(value)) {
81
81
  const {
82
82
  nodes
83
83
  } = nNode;
84
- const isStringValue = nodes.length !== 0 && nodes[0].type === 'string';
84
+ const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
85
85
  const url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
86
86
  const rule = {
87
87
  node: getNodeFromUrlFunc(nNode),
@@ -97,7 +97,7 @@ function visitor(result, parsedResults, node, key) {
97
97
  parsed
98
98
  });
99
99
  }
100
- } else if (type === 'string') {
100
+ } else if (type === "string") {
101
101
  const rule = {
102
102
  node: nNode,
103
103
  url: value,
@@ -124,13 +124,13 @@ function visitor(result, parsedResults, node, key) {
124
124
 
125
125
  const plugin = (options = {}) => {
126
126
  return {
127
- postcssPlugin: 'postcss-url-parser',
127
+ postcssPlugin: "postcss-url-parser",
128
128
 
129
129
  prepare(result) {
130
130
  const parsedResults = [];
131
131
  return {
132
132
  Declaration(declaration) {
133
- visitor(result, parsedResults, declaration, 'value');
133
+ visitor(result, parsedResults, declaration, "value");
134
134
  },
135
135
 
136
136
  async OnceExit() {
@@ -149,12 +149,12 @@ const plugin = (options = {}) => {
149
149
  isStringValue
150
150
  } = parsedResult.rule;
151
151
  let normalizedUrl = url;
152
- let prefix = '';
153
- const queryParts = normalizedUrl.split('!');
152
+ let prefix = "";
153
+ const queryParts = normalizedUrl.split("!");
154
154
 
155
155
  if (queryParts.length > 1) {
156
156
  normalizedUrl = queryParts.pop();
157
- prefix = queryParts.join('!');
157
+ prefix = queryParts.join("!");
158
158
  }
159
159
 
160
160
  normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl, isStringValue);
@@ -166,8 +166,8 @@ const plugin = (options = {}) => {
166
166
 
167
167
  if (!hasUrlImportHelper) {
168
168
  options.imports.push({
169
- importName: '___CSS_LOADER_GET_URL_IMPORT___',
170
- url: options.urlHandler(require.resolve('../runtime/getUrl.js')),
169
+ importName: "___CSS_LOADER_GET_URL_IMPORT___",
170
+ url: options.urlHandler(require.resolve("../runtime/getUrl.js")),
171
171
  index: -1
172
172
  });
173
173
  hasUrlImportHelper = true;
@@ -175,8 +175,8 @@ const plugin = (options = {}) => {
175
175
 
176
176
  const splittedUrl = normalizedUrl.split(/(\?)?#/);
177
177
  const [pathname, query, hashOrQuery] = splittedUrl;
178
- let hash = query ? '?' : '';
179
- hash += hashOrQuery ? `#${hashOrQuery}` : '';
178
+ let hash = query ? "?" : "";
179
+ hash += hashOrQuery ? `#${hashOrQuery}` : "";
180
180
  const request = (0, _utils.requestify)(pathname, options.rootContext);
181
181
  tasks.push((async () => {
182
182
  const {
@@ -242,7 +242,7 @@ const plugin = (options = {}) => {
242
242
  } // eslint-disable-next-line no-param-reassign
243
243
 
244
244
 
245
- rule.node.type = 'word'; // eslint-disable-next-line no-param-reassign
245
+ rule.node.type = "word"; // eslint-disable-next-line no-param-reassign
246
246
 
247
247
  rule.node.value = replacementName; // eslint-disable-next-line no-param-reassign
248
248
 
@@ -18,15 +18,15 @@ module.exports = function (cssWithMappingToString) {
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 === 'string') {
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 = {};
@@ -17,16 +17,16 @@ module.exports = function cssWithMappingToString(item) {
17
17
  content = _item[1],
18
18
  cssMapping = _item[3];
19
19
 
20
- if (typeof btoa === 'function') {
20
+ if (typeof btoa === "function") {
21
21
  // eslint-disable-next-line no-undef
22
22
  var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
23
23
  var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
24
24
  var sourceMapping = "/*# ".concat(data, " */");
25
25
  var sourceURLs = cssMapping.sources.map(function (source) {
26
- return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
26
+ return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
27
27
  });
28
- return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
28
+ return [content].concat(sourceURLs).concat([sourceMapping]).join("\n");
29
29
  }
30
30
 
31
- return [content].join('\n');
31
+ return [content].join("\n");
32
32
  };
@@ -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 !== 'string') {
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, '\\n'), "\"");
30
+ return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
31
31
  }
32
32
 
33
33
  return url;