Skip to content

Commit

Permalink
fix: vite typescript reflect-metadata bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cjhih456 committed Dec 21, 2023
1 parent b87c362 commit 66e226f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dist
dist-server

.env.*.local
auto-imports.d.ts
auto-imports.d.ts
.rollup.cache
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"devDependencies": {
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@rollup/plugin-typescript": "^11.1.5",
"@types/cookie-parser": "^1.4.6",
"@types/express": "^4.17.21",
"@types/lodash": "^4.14.202",
Expand All @@ -54,11 +55,12 @@
"terser": "^5.24.0",
"ts-node": "^10.9.1",
"typescript": "~4.7.4",
"unimport": "^3.6.1",
"unplugin-auto-import": "^0.17.2",
"unplugin-vue-components": "^0.26.0",
"vite": "^4.0.0",
"vite-plugin-checker": "^0.6.2",
"vite-plugin-ssr": "^0.4.142",
"vite-tsconfig-paths": "^4.2.2",
"vue-server-renderer": "^2.7.15",
"vue-tsc": "^1.8.25"
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/LayoutHeaderPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import HeaderDefault from '@/layout/header/HeaderDefault'
import type { Ref } from 'vue'
export const HeaderKey = 'headerKey'
export interface LayoutHeaderType {
headerName: Ref<string>,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["types/**/*.d.ts", "src/**/*", "src/auto-imports.d.ts"],
"include": ["types/**/*.d.ts", "src/auto-imports.d.ts", "src/**/*"],
"exclude": ["dist", "dist-server", "./outDir"],
"compilerOptions": {
"allowJs": true,
Expand Down
12 changes: 9 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import vueJsx from '@vitejs/plugin-vue2-jsx'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import { checker } from 'vite-plugin-checker'
import dotenv from 'dotenv'
import viteTsconfigPaths from 'vite-tsconfig-paths';
import AutoImport from 'unplugin-auto-import/vite'
import { VuetifyResolver } from 'unplugin-vue-components/resolvers'
import typescript from '@rollup/plugin-typescript'

export default defineConfig((env) => {
const processEnv = {} as ImportMetaEnv
Expand Down Expand Up @@ -50,16 +51,21 @@ export default defineConfig((env) => {
ssr: {
noExternal: ['vuetify']
},
esbuild: false,
plugins: [
viteTsconfigPaths(),
vue(),
vueJsx(),
AutoImport({
dts: true,
injectAtEnd: false,
include: [/\.vue$/, /\.vue\?vue/, /\.[jt]sx$/, /\.[jt]sx\?[jt]sx$/, /\.[jt]s$/],
defaultExportByFilename: true,
imports: [{ 'vue-router': ['RouterLink', 'RouterView'] }, 'vue', 'pinia'],
dirs: ['../node_modules/vuetify/lib/components/V[A-Z]*/index.js']
resolvers: VuetifyResolver()
}),
typescript({
include: ['./src/auto-imports.d.ts', './src/**/*.ts', './src/**/*.tsx'],
tsconfig: 'tsconfig.app.json'
}),
viteCommonjs(),
legacy({
Expand Down

0 comments on commit 66e226f

Please sign in to comment.