-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Bug report
What is the current behavior?
When enabling the CSS experiment and using the [contenthash] placeholder in output.chunkFilename and with async import in JavaScript files, the following error is thrown on build:
ERROR in Path variable [contenthash] not implemented in this context: [name].[contenthash].css
If the current behavior is a bug, please provide the steps to reproduce.
See https://github.com/titouanmathis/repro-webpack-contenthash-error
What is the expected behavior?
The build should not throw an error, and we should be able to use the [contenthash] placeholder for chunks' filename.
Other relevant information:
webpack version: 5.92.0
Node.js version: 20
Operating System: macOS
Additional tools: not relevant
Fix
I was able to identify the commit (c561748) introducing the bug with git bisect. The bug seems to occur when modules is undefined in lib/css/CssModulesPlugin.js:363. Wrapping the following lines in the condition below fixes the error.