vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

css modules InjectStyles bug in ssr #1866

Open zhangyuang opened 3 years ago

zhangyuang commented 3 years ago

Version

15.9.8

Reproduction link

https://github.com/zhangyuang/vue-loader-ssr-bug.git

Steps to reproduce

yarn && npm start

What is expected?

this.$style can be read the exact value in server and client side。

What is actually happening?

In server side this.$style value is {default : val} In client side this.$style value is exact value


By read the source code, vue-loader must be used with vue-style-loader to avoid the problem.But i needn't use vue-style-loader。Maybe vue-loader should fix the case by itself

samiconductor commented 2 years ago

Setting css-loader namedExport true solved a related problem for me.

UPD: Also found this option on mini css extract plugin esModules. Setting it to false did the trick and namedExport wasn't needed.

Hope that helps in case you're using either of those plugins.