8 Star 3 Fork 2

ahao/android-pack-tool-pc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
ahao 提交于 2024-07-22 11:50 . commit
import { defineConfig, loadEnv } from 'vite'
import path from 'node:path'
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 { VantResolver } from '@vant/auto-import-resolver';
import { createHtmlPlugin } from 'vite-plugin-html';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
console.log("mode", mode)
// 加载环境变量
const env = loadEnv(mode, process.cwd())
return {
plugins: [
createHtmlPlugin({
inject: {
data: {
title: env.VITE_TITLE,
// 传递环境变量
env: process.env,
},
}
}),
vue(),
electron({
main: {
// Shortcut of `build.lib.entry`.
entry: 'electron/main.ts',
vite: {
define: {
'process.env': {
...process.env,
...env,
},
}
}
},
preload: {
// Shortcut of `build.rollupOptions.input`.
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
input: path.join(__dirname, 'electron/preload.ts'),
},
// Ployfill the Electron and Node.js API for Renderer process.
// If you want use Node.js in Renderer process, the `nodeIntegration` needs to be enabled in the Main process.
// See 👉 https://github.com/electron-vite/vite-plugin-electron-renderer
renderer: env.NODE_ENV === 'test'
// https://github.com/electron-vite/vite-plugin-electron-renderer/issues/78#issuecomment-2053600808
? undefined
: {},
}),
AutoImport({
resolvers: [VantResolver()],
}),
Components({
resolvers: [VantResolver()],
}),
],
define: {
'process.env': {
...process.env,
...env,
}
},
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/UPUP0326/android-pack-tool-pc.git
git@gitee.com:UPUP0326/android-pack-tool-pc.git
UPUP0326
android-pack-tool-pc
android-pack-tool-pc
master

搜索帮助