请问在,electron项目中,如果通过vite.config.ts 配置绝对路径的resolve-alias?
我尝试对:
electron.vite.config.ts 配置,(按照main和renderer配置resolve-alias)
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
main: {
resolve: {
alias: {
'@main': path.resolve(__dirname, 'src/main')
}
},
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: {
alias: {
'@renderer': path.resolve(__dirname, 'src/renderer')
}
},
plugins: [react()]
}
})
但是实际不生效:
还需要修改 tsconfig.json 中的 path