Skip to content

Commit cc42a21

Browse files
committed
fix: resolve TypeScript errors in Vite config for pnpm ES modules
- Add @types/node dependency for Node.js type declarations - Update tsconfig.node.json to include Node.js types - Convert vite.config.ts to ES module patterns using import.meta.url - Replace __dirname with fileURLToPath for modern Node.js compatibility - Maintain all existing build optimizations and chunk splitting
1 parent 79fa266 commit cc42a21

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@tailwindcss/postcss": "^4.1.13",
1818
"@tailwindcss/typography": "^0.5.16",
1919
"@types/aos": "^3.0.7",
20+
"@types/node": "^24.4.0",
2021
"@vitejs/plugin-vue": "^6.0.1",
2122
"autoprefixer": "^10.4.21",
2223
"postcss": "^8.5.6",

tsconfig.node.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"module": "ESNext",
66
"moduleResolution": "bundler",
77
"allowSyntheticDefaultImports": true,
8-
"strict": true
8+
"strict": true,
9+
"types": ["node"]
910
},
1011
"include": ["vite.config.ts"]
1112
}

vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
import { resolve } from 'path'
3+
import { fileURLToPath, URL } from 'node:url'
44

55
export default defineConfig({
66
plugins: [vue()],
77
resolve: {
88
alias: {
9-
'@': resolve(__dirname, 'src'),
9+
'@': fileURLToPath(new URL('./src', import.meta.url)),
1010
},
1111
},
1212
build: {
@@ -24,7 +24,7 @@ export default defineConfig({
2424
},
2525
rollupOptions: {
2626
input: {
27-
main: resolve(__dirname, 'index.html'),
27+
main: fileURLToPath(new URL('./index.html', import.meta.url)),
2828
},
2929
output: {
3030
chunkFileNames: 'assets/js/[name]-[hash].js',

0 commit comments

Comments
 (0)