Skip to content

Commit 3c97405

Browse files
edmorleyjantimon
authored andcommitted
Address review comments
1 parent c920a15 commit 3c97405

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ class HtmlWebpackPlugin {
9999
this.options.filename = path.relative(compiler.options.output.path, filename);
100100
}
101101

102+
// Check if webpack is running in production mode
103+
// @see https://github.com/webpack/webpack/blob/3366421f1784c449f415cda5930a8e445086f688/lib/WebpackOptionsDefaulter.js#L12-L14
104+
const isProductionLikeMode = compiler.options.mode === 'production' || !compiler.options.mode;
105+
102106
const minify = this.options.minify;
103-
if (minify === true || (minify === undefined && compiler.options.mode === 'production')) {
107+
if (minify === true || (minify === undefined && isProductionLikeMode)) {
104108
this.options.minify = {
105109
// https://github.com/kangax/html-minifier#options-quick-reference
106110
collapseWhitespace: true,

typings.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface HtmlWebpackPluginOptions {
5353
* HTML Minification options
5454
* @https://github.com/kangax/html-minifier#options-quick-reference
5555
*/
56-
minify: undefined | boolean | {},
56+
minify?: boolean | {},
5757
cache: boolean,
5858
/**
5959
* Render errors into the HTML page

0 commit comments

Comments
 (0)