Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some stylesheet imports get excluded in vite build #49

Closed
troyvassalotti opened this issue Apr 25, 2022 · 3 comments
Closed

Some stylesheet imports get excluded in vite build #49

troyvassalotti opened this issue Apr 25, 2022 · 3 comments

Comments

@troyvassalotti
Copy link

troyvassalotti commented Apr 25, 2022

We have a vite project that uses this plugin in conjunction with Storybook and their vite builder. This plugin worked great out of the box when running the Storybook development server, but the plugin was not working when we built the static Storybook pages for publishing.

After opening an issue in the vite builder repo, the maintainer provided a fix that has to do with this plugin's default include setting. The link to his solution is here and I've copied it below for quick reference:

So, it seems that the default include from this plugin (**/*.{css,sss,pcss,styl,stylus,sass,scss,less}) is breaking with vite, because vite is adding query params to the id. So, for example, the stylesheet in this PR is becoming builder-vite/examples/lit-ts/stories/simplegreeting.scss?used, which is filtered out. I verified that updating the config as shown below fixes the issue:

// prettier-ignore
plugins: [postcssLit({ include: ['**/*.scss', '**/*.scss\?*'] })],

I can confirm that the above edits fixed our issue. Is this something worth adjusting the default include for?

@umbopepato
Copy link
Owner

Hey @troyvassalotti, thank you so much for reporting this! When Vite released the ?inline functionality I updated the readme but I didn't think to mention that the filter would have to be updated in order to work properly. Anyway I think including the query parameters suffix to the default filters would be a good idea. I'll take a look at #50 and your PR and see what I can do.
Thanks again for your help 🙂

@troyvassalotti
Copy link
Author

Thanks @umbopepato! Yeah #50 is a weird one because it seems to involve this plugin & Storybook & Vite all together so it's hard to pinpoint the underlying issue, but I appreciate whatever time you have!

mshabarov pushed a commit to vaadin/flow that referenced this issue Aug 9, 2022
Fixes #14142

Added rollup-plugin-postcss-lit and configured it to handle all CSS files except those under theme folder.
Note the extra entry with ? is necessary until umbopepato/rollup-plugin-postcss-lit#49 fixed.

Another entry added to excludes to workaround umbopepato/rollup-plugin-postcss-lit#52
@umbopepato
Copy link
Owner

I updated the default include glob so this should be solved. Feel free to reopen if the problem still exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants