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

Output .css file for styles instead of js strings #59

Open
antoniave opened this issue May 24, 2023 · 1 comment
Open

Output .css file for styles instead of js strings #59

antoniave opened this issue May 24, 2023 · 1 comment

Comments

@antoniave
Copy link
Member

antoniave commented May 24, 2023

Currently we are embedding the final styles for an application as a JavaScript string, i.e. const styles = "..." which is then loaded into a <style> tag.

This is triggered in our vite plugin, where we import the 'combined' css using the &inline query parameter, which prompts vite to return a raw css string to us (see https://github.com/open-pioneer/build-tools/blob/10112f6dfe15361e68fb48633d322b356fc20e7d/packages/vite-plugin/src/codegen/generateAppMetadata.ts#LL28C5-L29C88).

This approach has a number of disadvantages:

  • The built css is included in a JavaScript chunk, making editing unnecessarily hard
  • It worsens the developer experience (no source maps, no "jump to definition")

The &inline should be replaced by an &url, which would trigger vite to emit a .css asset and return its URL, not its content.

However, this was (and probably is still) blocked by vitejs/vite#2522 (context: our topmost css "entry point" uses SCSS to support both SCSS and CSS). There is an open pull request but there has been no progress for some time.

@mbeckem
Copy link
Collaborator

mbeckem commented Apr 17, 2024

Should be doable now with vite >= 5

@mbeckem mbeckem transferred this issue from open-pioneer/trails-starter Apr 17, 2024
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