1 Star 0 Fork 0

6xiaoxin/electron-teemplate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
6xiaoxin 提交于 2024-08-01 22:49 . 1
import { defineConfig, loadEnv } from 'vite'
import electron from 'vite-plugin-electron/simple'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'node:path'
export default ({ mode }) =>
defineConfig({
plugins: [
vue(),
electron({
main: {
entry: 'electron/main.ts'
},
preload: {
input: path.join(__dirname, 'electron/preload.ts')
},
renderer:
process.env.NODE_ENV === 'test'
? // https://github.com/electron-vite/vite-plugin-electron-renderer/issues/78#issuecomment-2053600808
undefined
: {}
}),
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
})
],
base:
process.env.NODE_ENV === 'production'
? getEnv(mode).VITE_PUBLIC_PATH
: './',
server: {
host: '0.0.0.0',
port: Number(getEnv(mode).VITE_PORT),
// open: Boolean(getEnv(mode).VITE_OPEN),
open: false,
proxy: {
'/api': {
target: getEnv(mode).VITE_API_URL,
ws: true,
changeOrigin: true,
secure: false
// rewrite: (path) => path.replace(/^\/api/, '/api')
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, '.', './src')
}
}
})
function getEnv(mode): Record<string, any> {
return loadEnv(mode, process.cwd())
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaoxin6a/electron-teemplate.git
git@gitee.com:xiaoxin6a/electron-teemplate.git
xiaoxin6a
electron-teemplate
electron-teemplate
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385