underfin / vite-plugin-vue2

Vue2 plugin for Vite
621 stars 84 forks source link

fix style of scoped #116

Closed kooriookami closed 3 years ago

kooriookami commented 3 years ago

The result of const block = descriptor.styles[index]; could be undefined. image

kooriookami commented 3 years ago

@underfin Could you please look at this?

underfin commented 3 years ago

I'm not sure the issue, can you give an reproduction for this?

kooriookami commented 3 years ago

I'm not sure the issue, can you give an reproduction for this?

@underfin Well, I try to make a small demo, but failed. May be it will happen in multiple style scripts. Like this:

<style lang="scss" src="../styles/common.scss"></style>
<style lang="scss" src="../styles/base.scss"></style>
<style lang="scss" scoped>
...
</style>
<style lang="scss">
...
</style>
<style lang="scss" src="../styles/dialog.scss"></style>

I print the value of descriptor.styles.length and index. The descriptor.styles.length is obviously wrong. I think it may be the compiler's mistake. For workaround, I have to change scoped: !!block.scoped to scoped: !!block?.scoped. image image If you need any other infomation, I can provide to you.

underfin commented 3 years ago

Sorry, I also can't get this error. Can you give me with detailed reproduction steps?

kooriookami commented 3 years ago

Sorry, I also can't get this error. Can you give me with detailed reproduction steps?

@underfin Finally, I get a demo. https://github.com/kooriookami/vite-plugin-vue2-scoped-error image

steps

clone and install

npm run build

You may try several times, somtimes it can build success, and most time it will build error.