Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,20 @@ Default: `true`

By default, `css-loader` generates JS modules that use the ES modules syntax.

This means you can import CSS using standard ES `import` syntax, which is the
recommended approach for modern JavaScript applications and frameworks
like React, Vue, and Angular.

Set `esModule: false` only if your environment expects CommonJS syntax
(for example, when using `require()` instead of `import`).

Using ES modules can be beneficial in some scenarios, such as module concatenation
and more consistent optimizations in modern JavaScript tooling. However,
tree-shaking may also work with CommonJS depending on the bundler configuration.
The `esModule` option primarily controls the export syntax generated by `css-loader`,
rather than enabling or disabling optimizations by itself.


There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).

You can enable CommonJS module syntax using:
Expand All @@ -1780,7 +1794,7 @@ module.exports = {
},
};
```

hh
### `exportType`

Type:
Expand Down Expand Up @@ -2336,6 +2350,8 @@ import * as styles from "Component.module.scss";
// Somewhere in JavaScript canvas drawing code use the variable directly
// const ctx = mountsCanvas.current.getContext('2d',{alpha: false});
ctx.fillStyle = `${svars.colorBackgroundCanvas}`;

kjk
```

## Contributing
Expand Down