mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 20:07:06 +08:00
refactor: inject process.env.NODE_ENV
This commit is contained in:
parent
c94327f87d
commit
66cb0b6abd
@ -19,7 +19,6 @@ const argv = minimist(process.argv.slice(2))
|
|||||||
const opts = options(argv.env)
|
const opts = options(argv.env)
|
||||||
const TAG = '[build-main.ts]'
|
const TAG = '[build-main.ts]'
|
||||||
const spinner = ora(`${TAG} Electron build...`)
|
const spinner = ora(`${TAG} Electron build...`)
|
||||||
process.env.NODE_ENV = argv.env
|
|
||||||
|
|
||||||
if (argv.watch) {
|
if (argv.watch) {
|
||||||
waitOn({ port: process.env.PORT as string }).then(msg => {
|
waitOn({ port: process.env.PORT as string }).then(msg => {
|
||||||
@ -32,7 +31,13 @@ if (argv.watch) {
|
|||||||
watcher.on('event', ev => {
|
watcher.on('event', ev => {
|
||||||
if (ev.code === 'END') {
|
if (ev.code === 'END') {
|
||||||
if (child) child.kill()
|
if (child) child.kill()
|
||||||
child = spawn(electron as any, [join(__dirname, `../${main}`)], { stdio: 'inherit' })
|
child = spawn(
|
||||||
|
electron as any,
|
||||||
|
[join(__dirname, `../${main}`)],
|
||||||
|
{
|
||||||
|
stdio: 'inherit',
|
||||||
|
env: Object.assign(process.env, { NODE_ENV: argv.env }),
|
||||||
|
})
|
||||||
} else if (ev.code === 'ERROR') {
|
} else if (ev.code === 'ERROR') {
|
||||||
console.log(ev.error)
|
console.log(ev.error)
|
||||||
}
|
}
|
||||||
|
2
typings/global.d.ts
vendored
2
typings/global.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
declare namespace NodeJS {
|
declare namespace NodeJS {
|
||||||
interface ProcessEnv {
|
interface ProcessEnv {
|
||||||
NODE_ENV: 'development' | 'production'
|
readonly NODE_ENV: 'development' | 'production'
|
||||||
readonly PORT: string
|
readonly PORT: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user