An error would thrown when CSS module called in an EJS Template, like this.
ERROR in ./src/pages/style.scss
No template for dependency: CssDependency
Error: No template for dependency: CssDependency
at JavascriptGenerator.sourceDependency (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:188:10)
at JavascriptGenerator.sourceModule (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
at JavascriptGenerator.generate (/home/user/data/dev/bloghaze/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
at NormalModule.codeGeneration (/home/user/data/dev/bloghaze/node_modules/webpack/lib/NormalModule.js:1208:22)
at /home/user/data/dev/bloghaze/node_modules/webpack/lib/Compilation.js:3332:22
at /home/user/data/dev/bloghaze/node_modules/webpack/lib/Cache.js:93:5
at Hook.eval [as callAsync] (eval at create (/home/user/data/dev/bloghaze/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Cache.get (/home/user/data/dev/bloghaze/node_modules/webpack/lib/Cache.js:75:18)
at ItemCacheFacade.get (/home/user/data/dev/bloghaze/node_modules/webpack/lib/CacheFacade.js:115:15)
at Compilation._codeGenerationModule (/home/user/data/dev/bloghaze/node_modules/webpack/lib/Compilation.js:3325:9)
@ ./src/pages/ sync ^\.\/.*$ ./style.scss
@ ./node_modules/html-webpack-plugin/lib/loader.js!./src/template.ejs 17:20-48
Child HtmlWebpackCompiler compiled with 1 error
After hours of debugging, I found out that CssDependencyTemplate is not injected to dependencyTemplates which assigned to the Compilation object for generating the code.
I moved the injection hook from thisCompilation to compilation to apply the template to all Compilation objects.
This PR contains a:
Motivation / Use-Case
An error would thrown when CSS module called in an EJS Template, like this.
After hours of debugging, I found out that
CssDependencyTemplate
is not injected todependencyTemplates
which assigned to theCompilation
object for generating the code.I moved the injection hook from
thisCompilation
tocompilation
to apply the template to allCompilation
objects.Breaking Changes
Additional Info