diff --git a/README.md b/README.md index 6a206e0..b0d7505 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ ] } ``` +- main 进程中暂时无法用 require,打包后会导致模块找不到 `21-02-18` ## 总结 diff --git a/src/main/index.ts b/src/main/index.ts index 9000d8c..22aaaca 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,10 +1,11 @@ /** * electron 主文件 */ -require('dotenv').config({ path: join(__dirname, '../../.env') }) - import { join } from 'path' import { app, BrowserWindow } from 'electron' +import dotenv from 'dotenv' + +dotenv.config({ path: join(__dirname, '../../.env') }) let win: BrowserWindow diff --git a/vite.config.ts b/vite.config.ts index 836a8d8..863d149 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,6 +10,7 @@ import { cjs2esm } from './script/utils' export default defineConfig({ plugins: [vue()], root: join(__dirname, 'src/render'), + base: './', // index.html 中静态资源加载位置 server: { port: +process.env.PORT, },