Skip to content

Commit

Permalink
fix: output warning when built-in CSS support enabled (#1520)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored May 18, 2023
1 parent 730f043 commit 0700ce8
Show file tree
Hide file tree
Showing 5 changed files with 574 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,8 @@ module.exports = {
module: {
rules: [
{
// If you enable `experiments.css` or `experiments.futureDefaults`, please uncomment line below
// type: "javascript/auto",
test: /\.(sa|sc|c)ss$/i,
use: [
devMode ? "style-loader" : MiniCssExtractPlugin.loader,
Expand Down
21 changes: 20 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,27 @@ import {

export default async function loader(content, map, meta) {
const rawOptions = this.getOptions(schema);
const plugins = [];
const callback = this.async();

if (
this._compiler &&
this._compiler.options &&
this._compiler.options.experiments &&
this._compiler.options.experiments.css &&
this._module &&
this._module.type === "css"
) {
this.emitWarning(
new Error(
'You can\'t use `experiments.css` (`experiments.futureDefaults` enable built-in CSS support by default) and `css-loader` together, please set `experiments.css` to `false` or set `{ type: "javascript/auto" }` for rules with `css-loader` in your webpack config (now css-loader does nothing).'
)
);

callback(null, content, map, meta);

return;
}

let options;

try {
Expand All @@ -44,6 +62,7 @@ export default async function loader(content, map, meta) {
return;
}

const plugins = [];
const replacements = [];
const exports = [];

Expand Down
Loading

0 comments on commit 0700ce8

Please sign in to comment.