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 [contentHash:8] issue in production #111

Open
meiyasan opened this issue Dec 21, 2022 · 1 comment
Open

Webpack [contentHash:8] issue in production #111

meiyasan opened this issue Dec 21, 2022 · 1 comment

Comments

@meiyasan
Copy link

meiyasan commented Dec 21, 2022

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
Copy link
Author

@SassNinja , not very accurate.

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

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

1 participant