Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5: incompatibility with compression-plugin #1525

Closed
csvan opened this issue Oct 5, 2020 · 2 comments
Closed

Webpack 5: incompatibility with compression-plugin #1525

csvan opened this issue Oct 5, 2020 · 2 comments

Comments

@csvan
Copy link

csvan commented Oct 5, 2020

Expected behaviour

html-webpack-plugin should output an index.html file which can then be compressed by the compression-plugin

Current behaviour

In Webpack 5 (tested in rc3), the index.html file seems to be output after the compression plugin runs. Hence, it is never compressed and the app breaks. This seems to be a general change in how wp5 handles the plugin lifecycle, but I can't figure it out.

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:

Node.js v14.13.0
darwin 19.6.0
[email protected]
[email protected]

Config

Copy the minimal webpack.config.js to produce this issue:

{
    plugins: [
        new HtmlWebpackPlugin({
            template: path.join(__dirname, 'index.html'),
            minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeRedundantAttributes: true,
                useShortDoctype: true,
                removeEmptyAttributes: true,
                removeStyleLinkTypeAttributes: true,
                keepClosingSlash: true,
                minifyJS: true,
                minifyCSS: true,
                minifyURLs: true,
            },
            inject: true
        }),
        new CompressionPlugin({
            filename: 'gzip/[path][base]',
            algorithm: 'gzip',
            test: /.*/,
            threshold: -1,
            minRatio: Number.MAX_SAFE_INTEGER,
        }),   
    ]
}

Additional context

This worked without issue under webpack 4. Analysing what gets fed to the compression-plugin, I see the following from html-webpack-plugin under webpack 5:

{
  file: '__child-HtmlWebpackPlugin_0',
  query: '',
  fragment: '',
  path: '',
  base: '__child-HtmlWebpackPlugin_0',
  name: '__child-HtmlWebpackPlugin_0',
  ext: ''
}
@jantimon
Copy link
Owner

jantimon commented Oct 16, 2020

Can you please see if this is fixed with [email protected] ?
Please see also #1527

@csvan
Copy link
Author

csvan commented Oct 16, 2020

Works as expected with [email protected]

@csvan csvan closed this as completed Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants