Skip to content

Commit

Permalink
fix: ensure intellisense for all create-app templates
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 12, 2021
1 parent 2b39f58 commit 589b295
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 33 deletions.
10 changes: 7 additions & 3 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,25 @@ 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({
// ...
})
```

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:
Expand Down
11 changes: 5 additions & 6 deletions packages/create-app/template-lit-element/vite.config.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -12,4 +11,4 @@ export default {
external: /^lit-element/
}
}
}
})
2 changes: 1 addition & 1 deletion packages/create-app/template-preact-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
13 changes: 4 additions & 9 deletions packages/create-app/template-preact/vite.config.js
Original file line number Diff line number Diff line change
@@ -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
})
2 changes: 1 addition & 1 deletion packages/create-app/template-react-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
10 changes: 4 additions & 6 deletions packages/create-app/template-react/vite.config.js
Original file line number Diff line number Diff line change
@@ -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()]
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
tsconfig setup:
<br />1. Install and add
<code>@vuedx/typescript-plugin-vue</code> to tsconfig plugins
<br />2. Delete shims-vue.d.ts
<br />2. Delete <code>src/shims-vue.d.ts</code>
<br />3. Open
<code>src/main.ts</code> in VSCode
<br />4. Open VSCode command input
Expand Down
10 changes: 4 additions & 6 deletions packages/create-app/template-vue/vite.config.js
Original file line number Diff line number Diff line change
@@ -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()]
}
})

0 comments on commit 589b295

Please sign in to comment.