IanVS/vite-plugin-turbosnap

CSS files imported from inside other CSS files aren't included in generated JSON file

s-robertson opened this issue · 0 comments

CSS files that are imported via a CSS @import aren't included in preview-stats.json.

For example, if I have a component that does import './index.css' and index.css has code such as the following:

@import './my-component.css'

index.css will show up inside preview-stats.json when you run a Storybook build, but my-component.css won't.

I was doing some debugging of this issue and it seems that in the moduleParsed Rollup hook, CSS imports aren't listed in the dynamicallyImportedIds or importedIds arrays. I'm assuming this is because Vite itself is using another Rollup plugin (css-import?) to handle @import statements, so the dependency info never makes its way to vite-plugin-turbosnap.

I'm wondering if this is something that vite-plugin-turbosnap might be able to support in some way? I'm not too familiar with Rollup plugins so I'm not sure if there's maybe another hook where the CSS import info is available?