Closed isidrok closed 6 years ago
This should be fixed now as long as you upgrade to the latest (0.4.4) mini-css-extract-plugin!
Closing since you gave it a thumbs up - let me know if you're still hitting issues!
Just tried with the new version of mini-css-extract-plugin and neither critters nor prerender-loader output any error but the referenced css file is still incorrect for dynamically imported modules.
If I remove prerender-loader and just use Critters the following error is thrown:
TypeError: Cannot read property 'textContent' of undefined
.
The css file referenced in the bundle under the comment mini-css-extract-plugin CSS loading
is correct though.
After looking at the mini-css-extract-plugin source it seems they are handling hashes on the hashForChunk
and contentHash
hooks, maybe that happens after prerender-loader does its work, will check later.
Edit: after debugging the reproduction repo I saw that mini-css-extract-plugin hooks are running twice, once before prerender-loader and once again inside (it is beign added to the new compiler plugins), and it seems different assets (with different names) are being generated on each compilation which seems normal since using hash
is supposed to create a different hash for each build?
Anyways I'm using contenthash
and it works just fine so it may be enough with having this issue as reference...
Summarizing the previous comment:
My guess is that since prerender-loader is creating a new compilation, when using a hash different from contenthash
it changes during that specific build and doesn't reference the assets of the main compilation.
That makes sense. Perhaps it'd be worth having the plugin warn when [hash]
is used.
Hi, when using
prerender-loader
in conjunction withmini-css-extract-plugin
there is an error loading CSS imported bydynamic-chunks
when the hashing strategy is different fromcontenthash
for that css file.In that case,
prerender-loader
outputs a link pointing to a CSS file with a different hash.Note that this doesn't apply to JS files nor to CSS files imported by the main (entrypoint) chunk.
A full reproduction is in https://github.com/isidrok/prerender-loader-reprod, look at the readme for more information.
The original discussion is in GoogleChromeLabs/critters#7