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

compilerOptions css does not bundle external css files #187

Open
jonnitto opened this issue Jun 27, 2023 · 1 comment
Open

compilerOptions css does not bundle external css files #187

jonnitto opened this issue Jun 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@jonnitto
Copy link

If I set compilerOptions.css to true (or `inject with Svelte 4), it still generates a CSS file and doesn't include it in the Javascript file.

To Reproduce
Steps to reproduce the behavior:

Import a css file into a svelte file

Expected behavior
The CSS is included into the JS and get's injected

Environment:

  • esbuild-svelte version: 0.7.3
  • esbuild version: 0.18.10
  • svelte-preprocess: 5.0.4
@jonnitto jonnitto added the bug Something isn't working label Jun 27, 2023
@EMH333 EMH333 changed the title Esbuild compilerOptions css not working properly compilerOptions css does not bundle external css files Jun 27, 2023
@EMH333
Copy link
Owner

EMH333 commented Jun 27, 2023

I can replicate this, but there is a bit of nuance as follows (all with css: "injected"):

  • Using @import "./test.css"; in component style results in the output js file still including the import statement but not copying the css file over
  • Using import "./test.css"; in the component script results in the test.css file being copied over but no import call from the component css
  • Using both @import and import results in a functioning component, with the imported css in an external file

None of these are exactly what you are looking for. Since Svelte deals with the css -> css-in-js transformation internally, there is limited ability for a bundler to interfere. I'll continue to think about possible solutions.

Since I see you are using svelte-preprocess, it might be worth looking into their sourcing solution https://github.com/sveltejs/svelte-preprocess#external-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants