You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this is then bundled by webpack, the generated output (with the webpack bootstrap removed) looks like the code below. This means that for each css file an object is defined to map the CSS classes; this object exported; the object is imported; and the property is read from the imported module.
I suggest to add an option to generate es6 modules instead. This es6 module would import all class mappings as a serie of exported constants. Because JavaScript constants may not have hyphens in their names, this always converts names to camel case.
This means that the example above would get converted to:
exportconstmyClassName='hash';
When this is combined with the ModuleConcatenationPlugin, the generated code looks like this:
All whole ecosystem e.g url/file-loader, style-loader, extract-text-webpack-plugin would break and there are other downsides to the current approach taken by css-loader anyways
Do you want to request a feature or report a bug? feature
What is the current behavior?
css-loader always outputs commonjs modules when
modules
is set totrue
.What is the expected behavior?
To have the ability to output es6 modules instead.
If this is a feature request, what is motivation or use case for changing the behavior?
Let's say there is a file
main.js
:And there is a file
style.css
:This would be converted to the following JavaScript module:
When this is then bundled by webpack, the generated output (with the webpack bootstrap removed) looks like the code below. This means that for each css file an object is defined to map the CSS classes; this object exported; the object is imported; and the property is read from the imported module.
I suggest to add an option to generate es6 modules instead. This es6 module would import all class mappings as a serie of exported constants. Because JavaScript constants may not have hyphens in their names, this always converts names to camel case.
This means that the example above would get converted to:
When this is combined with the
ModuleConcatenationPlugin
, the generated code looks like this:This has several benefits:
The text was updated successfully, but these errors were encountered: