diff --git a/docs/config/index.md b/docs/config/index.md index 2fe9e86a4a9cb9..33dc8d3d568d72 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -31,14 +31,16 @@ Since Vite ships with TypeScript typings, you can leverage your IDE's intellisen /** * @type {import('vite').UserConfig} */ -export default { +const config = { // ... } + +export default config ``` -Vite also directly supports TS config files. You can use `vite.config.ts` instead: +Alternatively you can use the `defineConfig` helper which should provide intellisense without the need for jsdoc annotations: -```ts +```js import { defineConfig } from 'vite' export default defineConfig({ @@ -46,6 +48,8 @@ export default defineConfig({ }) ``` +Vite also directly supports TS config files. You can use `vite.config.ts` with the `defineConfig` helper as well. + ### Conditional Config If the config needs to conditional determine options based on the command (`serve` or `build`) or the [mode](/guide/env-and-mode) being used, it can export a function instead: diff --git a/packages/create-app/template-lit-element/vite.config.js b/packages/create-app/template-lit-element/vite.config.js index b3e22b1e14bdf0..11ddab292226c2 100644 --- a/packages/create-app/template-lit-element/vite.config.js +++ b/packages/create-app/template-lit-element/vite.config.js @@ -1,8 +1,7 @@ -/** - * https://vitejs.dev/config/ - * @type {import('vite').UserConfig} - */ -export default { +import { defineConfig } from 'vite' + +// https://vitejs.dev/config/ +export default defineConfig({ build: { lib: { entry: 'src/my-element.js', @@ -12,4 +11,4 @@ export default { external: /^lit-element/ } } -} +}) diff --git a/packages/create-app/template-preact-ts/vite.config.ts b/packages/create-app/template-preact-ts/vite.config.ts index 39218c3adb8275..7514fad27af7f1 100644 --- a/packages/create-app/template-preact-ts/vite.config.ts +++ b/packages/create-app/template-preact-ts/vite.config.ts @@ -1,5 +1,5 @@ -import preactRefresh from '@prefresh/vite' import { defineConfig } from 'vite' +import preactRefresh from '@prefresh/vite' // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/create-app/template-preact/vite.config.js b/packages/create-app/template-preact/vite.config.js index 4869486c020f3a..35560da39ca851 100644 --- a/packages/create-app/template-preact/vite.config.js +++ b/packages/create-app/template-preact/vite.config.js @@ -1,17 +1,12 @@ -// @ts-check +import { defineConfig } from 'vite' import preactRefresh from '@prefresh/vite' -/** - * https://vitejs.dev/config/ - * @type { import('vite').UserConfig } - */ -const config = { +// https://vitejs.dev/config/ +export default defineConfig({ esbuild: { jsxFactory: 'h', jsxFragment: 'Fragment', jsxInject: `import { h, Fragment } from 'preact'` }, plugins: [preactRefresh()] -} - -export default config +}) diff --git a/packages/create-app/template-react-ts/vite.config.ts b/packages/create-app/template-react-ts/vite.config.ts index 8104540622572a..5e7342c934806b 100644 --- a/packages/create-app/template-react-ts/vite.config.ts +++ b/packages/create-app/template-react-ts/vite.config.ts @@ -1,5 +1,5 @@ -import reactRefresh from '@vitejs/plugin-react-refresh' import { defineConfig } from 'vite' +import reactRefresh from '@vitejs/plugin-react-refresh' // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/create-app/template-react/vite.config.js b/packages/create-app/template-react/vite.config.js index 0a33851d63976e..5e7342c934806b 100644 --- a/packages/create-app/template-react/vite.config.js +++ b/packages/create-app/template-react/vite.config.js @@ -1,9 +1,7 @@ +import { defineConfig } from 'vite' import reactRefresh from '@vitejs/plugin-react-refresh' -/** - * https://vitejs.dev/config/ - * @type { import('vite').UserConfig } - */ -export default { +// https://vitejs.dev/config/ +export default defineConfig({ plugins: [reactRefresh()] -} +}) diff --git a/packages/create-app/template-vue-ts/src/components/HelloWorld.vue b/packages/create-app/template-vue-ts/src/components/HelloWorld.vue index 2505146689be15..6be4cdeecfd4e8 100644 --- a/packages/create-app/template-vue-ts/src/components/HelloWorld.vue +++ b/packages/create-app/template-vue-ts/src/components/HelloWorld.vue @@ -33,7 +33,7 @@ tsconfig setup:
1. Install and add @vuedx/typescript-plugin-vue to tsconfig plugins -
2. Delete shims-vue.d.ts +
2. Delete src/shims-vue.d.ts
3. Open src/main.ts in VSCode
4. Open VSCode command input diff --git a/packages/create-app/template-vue/vite.config.js b/packages/create-app/template-vue/vite.config.js index 65be59b248d570..315212d69a7ba5 100644 --- a/packages/create-app/template-vue/vite.config.js +++ b/packages/create-app/template-vue/vite.config.js @@ -1,9 +1,7 @@ +import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' -/** - * https://vitejs.dev/config/ - * @type {import('vite').UserConfig} - */ -export default { +// https://vitejs.dev/config/ +export default defineConfig({ plugins: [vue()] -} +})