SassNinja / media-query-plugin

Webpack plugin for media query extraction.
MIT License
205 stars 27 forks source link

Webpack [contentHash:8] issue in production #111

Open meiyasan opened 1 year ago

meiyasan commented 1 year ago

Hello @SassNinja,

I have been facing some issues going from dev to prod in my project. The files are named with a contenthash variable at the end.

However, without specific configuration I end up with a filename like : /public/path/myfile.[contenthash:8].css The contenthash is not capture and so I configured MiniCssExtractPluging in my webpack as:

Encore.addPlugin(new MiniCssExtractPlugin({
        filename: '[name].[contenthash].css'
}))

However, this is still not working because the length of the contenthash is not 8 chars. Moreover, I would have expected same hash as the main entry it comes from, but this is not the case.

For instance, I have a "app" entry in my webpack configuration and files got a hash, the one from media-query-plugin another and they are not referenced in the entrypoint.json so I cannot use them. Any hint or solution maybe ?

meiyasan commented 1 year ago

@SassNinja , not very accurate.

                    const basename = this.options.filename
                                        .replace('[name]', mediaKey)
                                        .replace(/\[(content|chunk)?hash(?:\:[0-9]*)\]/, hash)
                                        .replace(/\.[^.]+$/, '');