Skip to content

Commit 0700ce8

Browse files
fix: output warning when built-in CSS support enabled (#1520)
1 parent 730f043 commit 0700ce8

File tree

5 files changed

+574
-1
lines changed

5 files changed

+574
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,8 @@ module.exports = {
16961696
module: {
16971697
rules: [
16981698
{
1699+
// If you enable `experiments.css` or `experiments.futureDefaults`, please uncomment line below
1700+
// type: "javascript/auto",
16991701
test: /\.(sa|sc|c)ss$/i,
17001702
use: [
17011703
devMode ? "style-loader" : MiniCssExtractPlugin.loader,

src/index.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,27 @@ import {
3131

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

36+
if (
37+
this._compiler &&
38+
this._compiler.options &&
39+
this._compiler.options.experiments &&
40+
this._compiler.options.experiments.css &&
41+
this._module &&
42+
this._module.type === "css"
43+
) {
44+
this.emitWarning(
45+
new Error(
46+
'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).'
47+
)
48+
);
49+
50+
callback(null, content, map, meta);
51+
52+
return;
53+
}
54+
3755
let options;
3856

3957
try {
@@ -44,6 +62,7 @@ export default async function loader(content, map, meta) {
4462
return;
4563
}
4664

65+
const plugins = [];
4766
const replacements = [];
4867
const exports = [];
4968

0 commit comments

Comments
 (0)