Closed Relaxe111 closed 1 year ago
What i am doing wrong?
you mixed up with a svelte.config.ts that contains vite config. note that svelte.config must be .js, ts config file is not supported for svelte
check the output of npm create vite@latest --template svelte-ts
for a working combo of vite and svelte config.
I recommend setting preprocess: vitePreprocess()
in svelte.config.js. Inline in vite plugin config works but other tooling, eg the vscode extension won't be able to pick it up
ok. How can i add additional configurations? I need to a adapt an vite.config.js file which works with vite v3 but can't make it work wil latest vite version? import { defineConfig } from 'vite'; import { resolve } from 'path'; import { svelte } from '@sveltejs/vite-plugin-svelte'; import { default as MicroVitePlugin } from '@micro-fe/vite-plugin';
//suggested vite.config.ts file
const VITE_APP_NAME = 'subapp3';
const DEV_HOST = 'localhost';
const DEV_PORT = 8003;
// TODO: change to real deploy domain
const DEPLOY_URL = 'http://localhost:8003';
const isProd = process.env.NODE_ENV === 'production';
const isMicro = process.env.VITE_MICRO_MODE === 'true';
let base = '/';
if (isProd) {
base = DEPLOY_URL;
} else if (isMicro) {
base = `/${VITE_APP_NAME}/`;
}
// https://vitejs.dev/config/
export default defineConfig({
base,
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
plugins: [
// ...(isProd ? svelte() : []),
svelte({}),
MicroVitePlugin(VITE_APP_NAME, {
useDevMode: !isProd,
}),
],
server: {
cors: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
port: DEV_PORT,
hmr: {
host: DEV_HOST,
port: DEV_PORT,
},
},
});
This tracker is for reproducible bugs with vite plugin svelte. For questions and support please use https://svelte.dev/chat help section
for issues with micro vite plugin i recommend contacting them directly
Describe the bug
When i add in vite.config.ts :
i get following:
repro: https://stackblitz.com/edit/vitejs-vite-anfcqc?file=svelte.config.ts,package.json&terminal=dev
Reproduction URL
https://stackblitz.com/edit/vitejs-vite-anfcqc?file=svelte.config.ts,package.json&terminal=dev
Reproduction
No response
Logs
No response
System Info