Skip to content

Commit

Permalink
fix: css experiments logic
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jan 9, 2024
1 parent 14e731e commit c4b80b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const loader = function loader(content) {
this._compiler.options.experiments &&
this._compiler.options.experiments.css &&
this._module &&
this._module.type === "css"
(this._module.type === "css" ||
this._module.type === "css/global" ||
this._module.type === "css/module" ||
this._module.type === "css/auto")
) {
return content;
}
Expand All @@ -43,7 +46,10 @@ loader.pitch = function pitch(request) {
this._compiler.options.experiments &&
this._compiler.options.experiments.css &&
this._module &&
this._module.type === "css"
(this._module.type === "css" ||
this._module.type === "css/global" ||
this._module.type === "css/module" ||
this._module.type === "css/auto")
) {
this.emitWarning(
new Error(
Expand Down
4 changes: 0 additions & 4 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ exports[`loader should do nothing with built-in CSS support: errors 1`] = `Array

exports[`loader should do nothing with built-in CSS support: warnings 1`] = `
Array [
"ModuleWarning: Module Warning (from ../../node_modules/css-loader/dist/cjs.js):
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).",
"ModuleWarning: Module Warning (from ../../src/cjs.js):
You can't use \`experiments.css\` (\`experiments.futureDefaults\` enable built-in CSS support by default) and \`style-loader\` together, please set \`experiments.css\` to \`false\` or set \`{ type: \\"javascript/auto\\" }\` for rules with \`style-loader\` in your webpack config (now \`style-loader\` does nothing).",
"ModuleWarning: Module Warning (from ../../node_modules/css-loader/dist/cjs.js):
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).",
"ModuleWarning: Module Warning (from ../../src/cjs.js):
You can't use \`experiments.css\` (\`experiments.futureDefaults\` enable built-in CSS support by default) and \`style-loader\` together, please set \`experiments.css\` to \`false\` or set \`{ type: \\"javascript/auto\\" }\` for rules with \`style-loader\` in your webpack config (now \`style-loader\` does nothing).",
]
Expand Down

0 comments on commit c4b80b4

Please sign in to comment.