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

Sveltekit Static Asset import ...css?url failure #9924

Closed
isaacwein opened this issue May 14, 2023 · 1 comment · Fixed by #9925
Closed

Sveltekit Static Asset import ...css?url failure #9924

isaacwein opened this issue May 14, 2023 · 1 comment · Fixed by #9925

Comments

@isaacwein
Copy link

Describe the bug

Sveltekit is assuming on a CSS file that is JS and throwing errors on trying to preprocess the file

Reproduction

I have a basic sveltekit v1.16.3 project with a css file like this

.mdc-image-list__image-aspect-container {
    padding-bottom: calc(100% / 1);
}

i have a svelte Component like this with Explicit URL Imports

<script lang="ts">
    import testCSS from './test.css?url'
    console.log(testCSS)
</script>
<svelte:head>
    <link rel="stylesheet" href="{testCSS}">
</svelte:head>

why dose vite preprocess the css at all?
why is it trying to process the css as js?

i made a Stackblitz

from my understanding the issue is because i made a import testCSS from './test.css?url' and sveltkit adds a query pram import testCSS from './test.css?url=&inline=' to it

i tried to make a plain vite ts project if i add &inline= it happens the same issue so i think that sveltekit should stop to add inline query on assists let vite do the job

Logs

when i run i am getting this error


/src/routes/test.css
Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .css?url=&inline= file format, or if it's an asset, add "**/*.css?url=&inline=" to `assetsInclude` in your configuration.
  Plugin: vite:import-analysis
  File: /home/projects/parilmppm.github/src/routes/test.css?url=&inline=:2:36
  1  |  .mdc-image-list__image-aspect-container {
  2  |      padding-bottom: calc(100% / 1);
     |                                     ^
  3  |  }

System Info

I reproduced it in StackBlit Results from StackBlit
success Install finished in 1.002s


  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.1 => 2.0.1 
    @sveltejs/kit: ^1.16.3 => 1.16.3 
    svelte: ^3.59.1 => 3.59.1 
    vite: ^4.3.5 => 4.3.5

Severity

blocking all usage of SvelteKit

Additional Information

No response

@isaacwein
Copy link
Author

this is an image
image

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

Successfully merging a pull request may close this issue.

1 participant