Skip to content

Commit

Permalink
Merge branch 'master' into optimize-locals
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Apr 16, 2024
2 parents ace213e + e73061d commit fc80832
Show file tree
Hide file tree
Showing 14 changed files with 1,188 additions and 917 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ module.exports = {
- **[`publicPath`](#publicPath)**
- **[`emit`](#emit)**
- **[`esModule`](#esModule)**
- **[`defaultExport`](#defaultExport)**

#### `publicPath`

Expand Down Expand Up @@ -549,6 +550,60 @@ module.exports = {
};
```

#### `defaultExport`

Type:

```ts
type defaultExport = boolean;
```

Default: `false`

> **Note**
>
> This option will work only when you set `namedExport` to `true` in `css-loader`
By default, `mini-css-extract-plugin` generates JS modules based on the `esModule` and `namedExport` options in `css-loader`.
Using the `esModule` and `namedExport` options will allow you to better optimize your code.
If you set `esModule: true` and `namedExport: true` for `css-loader` `mini-css-extract-plugin` will generate **only** a named export.
Our official recommendation is to use only named export for better future compatibility.
But for some applications, it is not easy to quickly rewrite the code from the default export to a named export.

In case you need both default and named exports, you can enable this option:

**webpack.config.js**

```js
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
plugins: [new MiniCssExtractPlugin()],
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
defaultExport: true,
},
},
{
loader: "css-loader",
esModule: true,
modules: {
namedExport: true,
},
},
],
},
],
},
};
```

## Examples

### Recommended
Expand Down
Loading

0 comments on commit fc80832

Please sign in to comment.