Skip to content

Commit

Permalink
feat: add possibility to extend default minimize options
Browse files Browse the repository at this point in the history
  • Loading branch information
fretfan committed Jan 2, 2022
1 parent 576b781 commit c1ba176
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion README.md
Expand Up @@ -534,7 +534,7 @@ module.exports = {

See [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)'s documentation for more information on the available options.

The rules can be disabled using the following options in your `webpack.conf.js`
The default rules can be overridden using the following options in your `webpack.conf.js`

**webpack.config.js**

Expand All @@ -556,7 +556,31 @@ module.exports = {
},
};
```
The default rules can be extended:

**webpack.config.js**

```js
const defaultMinimizerOptions = require('html-loader/dist/utils').defaultMinimizerOptions;

module.exports = {
module: {
rules: [
{
test: /\.html$/i,
loader: "html-loader",
options: {
minimize: {
...defaultMinimizerOptions,
removeComments: false,
collapseWhitespace: false,
},
},
},
],
},
};
```
### `esModule`

Type: `Boolean`
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Expand Up @@ -496,7 +496,7 @@ function isProductionMode(loaderContext) {
return loaderContext.mode === "production" || !loaderContext.mode;
}

const defaultMinimizerOptions = {
export const defaultMinimizerOptions = {
caseSensitive: true,
// `collapseBooleanAttributes` is not always safe, since this can break CSS attribute selectors and not safe for XHTML
collapseWhitespace: true,
Expand Down

0 comments on commit c1ba176

Please sign in to comment.