Skip to content

Commit

Permalink
pack: 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 7da4d76 commit e5ae1ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"url": "https://github.com/jooy2/vutron/issues"
},
"scripts": {
"dev": "cross-env ELECTRON_ENABLE_LOGGING=true vite",
"dev": "vite",
"dev:debug": "vite -d",
"dev:debug:force": "vite -d --force",
"build": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js",
"build:pre": "npm run format:fix && vue-tsc --noEmit && cross-env NODE_ENV=production vite build",
"build:pre": "npm run format:fix && vue-tsc --noEmit && vite build",
"build:all": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js -wml",
"build:dir": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js --dir",
"build:mac": "npm run build:pre && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --config=buildAssets/builder/config.js --mac",
Expand Down Expand Up @@ -48,7 +48,6 @@
"@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-vue": "^4.4.1",
"@vitejs/plugin-vue-jsx": "^3.0.2",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"electron": "^27.0.4",
"electron-builder": "^24.6.4",
Expand Down
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 isDevEnv = process.env.NODE_ENV === 'development'

export default defineConfig(() => {
export default defineConfig(({ mode }) => {
process.env = {
...(isDevEnv
? {
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 e5ae1ca

Please sign in to comment.