npm scripts设置环境变量,NODE_ENV
windows
set NODE_ENV=production
"scripts": {
"build": "set NODE_ENV=production && rollup -c",
"dev": "set NODE_ENV=development && rollup -wc",
}
linux & mac
export NODE_ENV=production
"scripts": {
"build": "NODE_ENV=production rollup -c",
"dev": "NODE_ENV=development rollup -wc",
}
跨平台设置
依赖 cross-env 模块
npm install -D cross-env
"scripts": {
"build": "cross-env NODE_ENV=production rollup -c",
"dev": "cross-env NODE_ENV=development rollup -wc",
}