-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
cross-dev 运用,控制程序打包环境
安装包:npm install cross-env --save-dev
vue-cli2 中使用
"scripts": {
"start:main": "cross-env NODE_ENV=development electron ."
}
vue-cli3 不用配置
"scripts": {
本地开发运行,会把process.env.NODE_ENV设置为'development'
"dev": "vue-cli-service serve",
默认打包模式,会把process.env.NODE_ENV设置为'production'
"build": "vue-cli-service build"
}
NODE_ENV 原生的使用方式
linux 系统中的使用
"scripts": {
"start:main": "EXPORT NODE_ENV=development electron ."
}
windows系统中的使用
"scripts": {
"start:main": "SET NODE_ENV=development electron ."
}
mac系统中的使用
"scripts": {
"start:main": "NODE_ENV=development electron ."
}
webpack中的使用
module.exports = {
plugins: [
// 设置环境变量信息
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
]
}
Metadata
Metadata
Assignees
Labels
No labels