-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Invalid CSS file name caused by brackets and +
#5843
Comments
This was previously happening with JS files, but was fixed for that case: #1974 (comment) Anyway, this likely isn't generated by SvelteKit, but by Vite. Please file the issue there if you'd like it to be seen by anyone likely to fix it: https://github.com/sveltejs/kit#bug-reporting |
@benmccann did you mean to put the sveltekt bug-reporting link above? |
@eahrold that is the link I mean to share. Did you read what's there? It describes how to report issues to Vite that affect SvelteKit projects. I'm not exactly sure which PR changed the behavior in Vite for JS files It could also be from Rollup. Understanding whether it's Vite or Rollup responsible for this logic would be a good first step |
I'm also running into this now. With the new routing, all route related files are prepended with My project works fine in @eahrold Did you find any related issue on the Vite repo? Or know of any workaround? |
+
We've narrowed it down to this function in Vite, which is supplying an invalid filename to Rollup (which has no choice but to use the supplied const name = basename.slice(0, -extname.length) |
I made a quick workaround for my case using vite's plugin system to override the config sveltekit sets. Add to vite.config plugins after sveltekit. This only fixes /** @type {import('vite').UserConfig} */
const config = {
plugins: [
sveltekit(),
// <workaround for https://github.com/sveltejs/kit/issues/5843>
{
config(config) {
const original = config.build.rollupOptions.output.assetFileNames;
config.build.rollupOptions.output.assetFileNames = assetInfo => {
const match = assetInfo.name.match(/\/\+(.*)\.css$/);
return match ? original.replace('[name]', match[1]) : original;
};
return config;
}
},
// </workaround>
]
}; |
Can this issue be closed or is the bug still relevant? |
The fix in Vite has not been released yet. We should keep this open until we confirm that the fix works. |
Hi @mattosborn, I'm getting below error when trying to run the application locally
It's coming from Vite config. |
@souravjamwal77 the issue with the invalid file names only happens during build and not during development, so the workaround should only be applied during build: {
config(config) {
const original = config.build.rollupOptions.output.assetFileNames;
config.build.rollupOptions.output.assetFileNames = (assetInfo) => {
const match = assetInfo.name.match(/\/\+(.*)\.css$/);
return match ? original.replace('[name]', match[1]) : original;
};
return config;
},
apply: 'build'
} |
Describe the bug
When a wild card route is used, and the application is build with the
adapter-node
the resulting .css file has square brackets in the file name which should be escaped.This is not a problem with serving with node directly, however when proxied through some non-js routers the route is considered invalid, as per various specs. (i.e. I'm serving the node application in a docker container, and have a proxy server intercepting requests and forwarding them to the node server)
and if you pass the route through encodeURI it too escapes the brackets
Demo of the URL format when used in Java
Reproduction
https://github.com/eahrold/svelte-kit-invalid-css-path
The problem
.css
file is herehttps://github.com/eahrold/svelte-kit-invalid-css-path/tree/main/build/client/_app/immutable/assets
The corresponding
.js
file works and looks to be processed differently.https://github.com/eahrold/svelte-kit-invalid-css-path/tree/main/build/client/_app/immutable/pages
The browser request doesn't encode the url
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: