preactjs / compressed-size-action

GitHub Action that adds compressed size changes to your PRs.
https://github.com/marketplace/actions/compressed-size-action
MIT License
602 stars 84 forks source link

[enhancement] Webpack chunks #13

Closed bartlomiejzuber closed 4 years ago

bartlomiejzuber commented 4 years ago

This action doesn't work well when build produces chunks with generated hash.

image

Please make it possible to provide stripHashRegex which will be passed to stripHash function of https://github.com/GoogleChromeLabs/size-plugin .

Will try to provide PR with change with this.

developit commented 4 years ago

That would be a lovely improvement! This action uses size-plugin-core, which should be able to perform the hash stripping, so my guess is that this is actually a bug.

moretti commented 4 years ago

One workaround is to use process.env.GITHUB_ACTIONS in webpack.config.js to determine when the build task runs from Github and use an alternative naming convention for chunks, eg.

output: {
    chunkFilename: process.env.GITHUB_ACTIONS
        ? '[name].js'
        : '[id].js',
}

(see https://webpack.js.org/configuration/output/#outputchunkfilename)

developit commented 4 years ago

Custom strip-hash support was released in v2. The hashes shown in this issue can be normalized using the following configuration:

    strip-hash: "\\.(\\w{8})\\.chunk\\.js$"

This will convert build/static/js/12.5034h92h.chunk.js to build/static/js/12.********.chunk.js.