Open freshgiammi opened 1 month ago
Duplicate of #13998 Nope, it's different.
~Duplicate of #13998~ Nope, it's different.
Well they do seem to share the root issue: there's no way to filter out the @import
statements.
I didn't come across that issue when searching before opening this one, I guess in a way it is a duplicate (unless we treat this as 'not being able to configure postcss-import
' entirely)?
Yeah, it shares some parts. But I think it's fine to have it separately because #13998 wants to externalize a CSS file in both dev and build, and this issue wants to externalize a CSS file only in build.
Describe the bug
I'm building a library which exports some css, but also imports some more from a second library.
The objective I'm pursuing is not to extract CSS files coming from a component library and keep them as imports, since that library itself will be already used by all consumers. Doing so also gets rid of possible specificity issues as the component library is always imported before the library's own styles.
The CSS is simple enough:
where an import is stated before tailwindcss' own styles. Since Vite provides
@import
inlining (as stated here), this import statement gets extracted and the content is merged in the output .css file.Currently, it seems as there's no way to exclude certain import statements from getting inlined. This should be doable with
postcss-import
(usingfilter
), however Vite already uses this plugin internally, and it seems like there's no way to configure it. Additionally, providing the postcss plugin in thecss.postCss.plugins
array seems to ignore the plugin (possibly getting skipped as it's a duplicate plugin?).Is there a way to achieve this result and if not, can a way to exclude imports be proposed so that there's more flexibility here?
These issues/questions seem related:
postcss-import
)Reproduction
https://stackblitz.com/edit/vitejs-vite-t6nqaz
Steps to reproduce
npm run build
System Info
Used Package Manager
pnpm
Logs
No response
Validations