Skip to content

Commit

Permalink
set vite env configuration instead of use cross-env package
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed Nov 13, 2023
1 parent 3f7c139 commit 16b25ba
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import ElectronPlugin, { ElectronOptions } from 'vite-plugin-electron';
import RendererPlugin from 'vite-plugin-electron-renderer';
import EslintPlugin from 'vite-plugin-eslint';
Expand All @@ -12,7 +12,17 @@ import { builtinModules } from 'module';

const isDEV = process.env.NODE_ENV === 'development';

export default defineConfig(() => {
export default defineConfig(({ mode }) => {
process.env = {
...(isDEV
? {
ELECTRON_ENABLE_LOGGING: 'true',
}
: {}),
...process.env,
...loadEnv(mode, process.cwd()),
};

rmSync('dist', { recursive: true, force: true });

const electronPluginConfigs: ElectronOptions[] = [
Expand Down

0 comments on commit 16b25ba

Please sign in to comment.