Skip to content

Commit 9457d3e

Browse files
committed
chore: add workaround
1 parent 9674ec4 commit 9457d3e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

packages/e2e-tests/kit-node/vite.config.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { sveltekit } from '@sveltejs/kit/vite';
22
import { transformValidation, writeResolvedConfig } from 'e2e-test-dep-vite-plugins';
33

44
/** @type {import('vite').UserConfig} */
5-
const config = {
5+
export default {
66
server: {
77
watch: {
88
// During tests we edit the files too fast and sometimes chokidar
@@ -15,11 +15,33 @@ const config = {
1515
minify: false,
1616
sourcemap: true // must be true for hermetic build test!
1717
},
18-
plugins: [transformValidation(), sveltekit(), writeResolvedConfig()],
18+
plugins: [
19+
transformValidation(),
20+
sveltekit(),
21+
writeResolvedConfig(),
22+
workaroundInlineSvelteCssIssue()
23+
],
1924
optimizeDeps: {
2025
// eagerly include these, otherwise vite optimizer might interfere with restarting while the test is running
2126
include: ['svelte-i18n', 'e2e-test-dep-svelte-api-only']
2227
}
2328
};
2429

25-
export default config;
30+
/**
31+
* Workaround until https://github.com/sveltejs/kit/pull/13007 is merged
32+
* @returns {import('vite').Plugin}
33+
*/
34+
function workaroundInlineSvelteCssIssue() {
35+
return {
36+
name: 'workaround-inline-svelte-css-issue',
37+
enforce: 'pre',
38+
resolveId(id) {
39+
// SvelteKit relies on a previous behaviour in v-p-s where it strips out the inline
40+
// query to get the CSS result, however this no longer works in Vite 6 and should be
41+
// fixed in SvelteKit instead, otherwise FOUC will happen in dev.
42+
if (id.includes('?svelte')) {
43+
return id.replace(/&inline=$/, '');
44+
}
45+
}
46+
};
47+
}

0 commit comments

Comments
 (0)