Skip to content

Commit 589b295

Browse files
committed
fix: ensure intellisense for all create-app templates
1 parent 2b39f58 commit 589b295

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

docs/config/index.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,25 @@ Since Vite ships with TypeScript typings, you can leverage your IDE's intellisen
3131
/**
3232
* @type {import('vite').UserConfig}
3333
*/
34-
export default {
34+
const config = {
3535
// ...
3636
}
37+
38+
export default config
3739
```
3840

39-
Vite also directly supports TS config files. You can use `vite.config.ts` instead:
41+
Alternatively you can use the `defineConfig` helper which should provide intellisense without the need for jsdoc annotations:
4042

41-
```ts
43+
```js
4244
import { defineConfig } from 'vite'
4345

4446
export default defineConfig({
4547
// ...
4648
})
4749
```
4850

51+
Vite also directly supports TS config files. You can use `vite.config.ts` with the `defineConfig` helper as well.
52+
4953
### Conditional Config
5054

5155
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:
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
/**
2-
* https://vitejs.dev/config/
3-
* @type {import('vite').UserConfig}
4-
*/
5-
export default {
1+
import { defineConfig } from 'vite'
2+
3+
// https://vitejs.dev/config/
4+
export default defineConfig({
65
build: {
76
lib: {
87
entry: 'src/my-element.js',
@@ -12,4 +11,4 @@ export default {
1211
external: /^lit-element/
1312
}
1413
}
15-
}
14+
})

packages/create-app/template-preact-ts/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import preactRefresh from '@prefresh/vite'
21
import { defineConfig } from 'vite'
2+
import preactRefresh from '@prefresh/vite'
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
// @ts-check
1+
import { defineConfig } from 'vite'
22
import preactRefresh from '@prefresh/vite'
33

4-
/**
5-
* https://vitejs.dev/config/
6-
* @type { import('vite').UserConfig }
7-
*/
8-
const config = {
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
96
esbuild: {
107
jsxFactory: 'h',
118
jsxFragment: 'Fragment',
129
jsxInject: `import { h, Fragment } from 'preact'`
1310
},
1411
plugins: [preactRefresh()]
15-
}
16-
17-
export default config
12+
})

packages/create-app/template-react-ts/vite.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import reactRefresh from '@vitejs/plugin-react-refresh'
21
import { defineConfig } from 'vite'
2+
import reactRefresh from '@vitejs/plugin-react-refresh'
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { defineConfig } from 'vite'
12
import reactRefresh from '@vitejs/plugin-react-refresh'
23

3-
/**
4-
* https://vitejs.dev/config/
5-
* @type { import('vite').UserConfig }
6-
*/
7-
export default {
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
86
plugins: [reactRefresh()]
9-
}
7+
})

packages/create-app/template-vue-ts/src/components/HelloWorld.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
tsconfig setup:
3434
<br />1. Install and add
3535
<code>@vuedx/typescript-plugin-vue</code> to tsconfig plugins
36-
<br />2. Delete shims-vue.d.ts
36+
<br />2. Delete <code>src/shims-vue.d.ts</code>
3737
<br />3. Open
3838
<code>src/main.ts</code> in VSCode
3939
<br />4. Open VSCode command input
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { defineConfig } from 'vite'
12
import vue from '@vitejs/plugin-vue'
23

3-
/**
4-
* https://vitejs.dev/config/
5-
* @type {import('vite').UserConfig}
6-
*/
7-
export default {
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
86
plugins: [vue()]
9-
}
7+
})

0 commit comments

Comments
 (0)