npm scripts設定環境變數方法

看風景就發表於2017-08-12

windows

set NODE_ENV=production

"scripts": {
    "release": "set NODE_ENV=production && gulp rtm",
    "dev": "set NODE_ENV=development && gulp watch",
}

linux & mac

export NODE_ENV=production

"scripts": {
    "release": "NODE_ENV=production gulp rtm",
    "dev": "NODE_ENV=development gulp watch",
}

cross-env跨平臺設定

npm i cross-env -D

"scripts": {
    "release": "cross-env NODE_ENV=production gulp rtm",
    "dev": "cross-env NODE_ENV=development gulp watch",
}

 

相關文章