Skip to content

Plugin should update contenthash after minification #18

@jakub-g

Description

@jakub-g

This is a behavior that was probably in place forever with uglify hence it remains with terser as well.

versions

  • webpack Version: 4.20.1
  • terser-webpack-plugin Version: 1.1.0

config

    output: {
        filename = 'myprefix.[name].[contenthash].js',
        chunkFilename = 'myprefix.[name].[contenthash].js'
    },
    optimization: {
-       minimize: false,
+       minimize: true,
        minimizer: [new TerserPlugin()],
    }

Expected Behavior

  • When minification is on, contenthash of the output files should be different compared to when it is off

Actual Behavior

  • Regardless if minification is on or off, same contenthash is generated. i.e. file names are the same

This is problematic in case of scenario of upgrading the minificator.

  • Since minification has no impact on the final file name, minifying with plugin version N vs plugin version N+1 might yield different content out of the same input file, yet same file name.
  • Problematic in scope of long term caching, particularly in case of a bug in minificator. This can yield weird problems in deployment pipelines, CDNs etc. or lead to situation where different users have file with same name but different contents, depending on when they access the files and how the caching headers are configured.

To sum up, hard to diagnose bugs can happen if you're not aware of this issue.

According to webpack/webpack#7483 (comment)

plugin should regenerate contenthash if they change content of file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions