css-loader 7.1.4 → 7.1.5

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 CHANGED
@@ -16,6 +16,14 @@
16
16
 
17
17
  # css-loader
18
18
 
19
+ > [!WARNING]
20
+ >
21
+ > **`css-loader` is deprecated** — webpack parses CSS itself and no longer needs it.
22
+ >
23
+ > Read the [Native CSS guide](https://webpack.js.org/guides/native-css/) and follow its [migration guide](https://webpack.js.org/guides/native-css/#migration-guide).
24
+ >
25
+ > Existing setups keep working: built-in CSS support stays off for any `.css` rule that already has a loader, so you can migrate one rule at a time.
26
+
19
27
  The `css-loader` interprets `@import` and `url()` like `import/require()` and resolves them.
20
28
 
21
29
  ## Getting Started
@@ -42,6 +50,12 @@ or
42
50
  pnpm add -D css-loader
43
51
  ```
44
52
 
53
+ In the example configuration below, `style-loader` is used to inject the processed CSS into the DOM during runtime. You may need to install it as well:
54
+
55
+ ```console
56
+ npm install --save-dev style-loader
57
+ ```
58
+
45
59
  Then, add the loader to your `webpack` configuration. For example:
46
60
 
47
61
  **file.js**
package/dist/index.js CHANGED
@@ -108,7 +108,7 @@ async function loader(content, map, meta) {
108
108
  } = this;
109
109
  let result;
110
110
  try {
111
- result = await (0, _postcss.default)(plugins).process(content, {
111
+ result = await (0, _postcss.default)(plugins).process((0, _utils.stripBom)(content), {
112
112
  hideNothingWarning: true,
113
113
  from: resourcePath,
114
114
  to: resourcePath,
package/dist/utils.js CHANGED
@@ -27,6 +27,7 @@ exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
27
27
  exports.shouldUseURLPlugin = shouldUseURLPlugin;
28
28
  exports.sort = sort;
29
29
  exports.stringifyRequest = stringifyRequest;
30
+ exports.stripBom = stripBom;
30
31
  exports.supportTemplateLiteral = supportTemplateLiteral;
31
32
  exports.syntaxErrorFactory = syntaxErrorFactory;
32
33
  exports.warningFactory = warningFactory;
@@ -1065,4 +1066,20 @@ function supportTemplateLiteral(loaderContext) {
1065
1066
  return true;
1066
1067
  }
1067
1068
  return false;
1069
+ }
1070
+ const BOM_CODE_POINT = 0xfeff;
1071
+
1072
+ // postcss stripped a leading BOM until 8.5.24 and preserves it since, so strip
1073
+ // it ourselves: concatenated stylesheets must not carry one in the middle.
1074
+ // `content` is a postcss `Root` when a previous loader handed over its AST,
1075
+ // and there the BOM lives on the input rather than in the tree.
1076
+ function stripBom(content) {
1077
+ if (typeof content === "string") {
1078
+ return content.charCodeAt(0) === BOM_CODE_POINT ? content.slice(1) : content;
1079
+ }
1080
+ if (content && content.source && content.source.input) {
1081
+ // eslint-disable-next-line no-param-reassign
1082
+ content.source.input.hasBOM = false;
1083
+ }
1084
+ return content;
1068
1085
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "7.1.4",
3
+ "version": "7.1.5",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack/css-loader",