0.14.0
Create a vue component in .vuepress/components
<template>
<p class="red">Should be red</p>
</template>
<style scoped>
.red {
color: red
}
</style>
Add "sideEffects": false to package.json file
The scoped attribute doesn't have an impact
When runnig the build, the css should be extracted in a CSS file
The CSS is dropped at some point, but it works correctly under dev
I just created a reproduction repo for it but cannot repro it, did I miss something?
You can find the css has been be extracted in the CSS file.
Ups missclick, although, it's probably a problem on my end then.
The problem happens in vue router docs, but it's too big for a repro, unless you want to give it a look and maybe send a pr 馃槆
This is the branch: https://github.com/vuejs/vue-router/tree/feat/docs-live-examples
Closing as it looks like a problem in my end
I'm going crazy. There is something in vue-router repo that is causing a side effect on vuepress but I don't know what. I will try adding files and dependencies. Copying the whole docs folder (plus adding raw-loader and vue-theme) yields the correct result
Finally found the problem: it's adding sideEffects: false to package.json file (it's a webpack thing for libraries). I created a pull request adding that to the package.json file: https://github.com/ulivz/vuepress-718/pull/1
Oh, just confirmed for that, the styles are truly lost 馃槼
maybe it's an upstream bug, coming from webpack or one the plugins or maybe a simple conf to add to webpack. I am also looking at it, trying my best to find where this comes from. Not easy 馃槅
I found a related issue: https://github.com/webpack/webpack/issues/6741.
CSS usually doesn't produce an export, so it really should be excluded from tree shaking.
After change sideEffects: false to:
"sideEffects": [
"*.vue"
],
The style comes back.
what do we do here? Documenting this should be enough but we could even emit a warning by reading the package.json file (if this is something already being done in vuepress). I think documenting this is enough, at least now there is this issue as a reference
Well, I think we should emit a warning.
Since the next version (monorepo) is almost done, adding a new feature request to the master will take time to resolve the conflict, so we try to avoid new commits (except docs or bug fixes) to the master. and I'll add this warning directly at next version.
but we can document it now.
Most helpful comment
I found a related issue: https://github.com/webpack/webpack/issues/6741.
After change
sideEffects: falseto:The style comes back.