cross-env & shelljs & set custom node.js env All In One
cross-env & shelljs & set custom node.js env All In One
单个 process 直接执行 ✅ vs && 多个 process ❌
PORT_ENV
https://github.com/xgqfrms/set-process-env
install
$ yarn global add set-process-env
# OR
$ npm i -g set-process-env
usage
# PORT_ENV for webpack
$ spe PORT_ENV=8090
demo
// webpack.config.js
const PORT = process.env.PORT_ENV || 8080;
console.log('PORT_ENV =', process.env.PORT_ENV);
// const ip = require('ip');
// const hostIp = ip.address();
const config = {
// ...
devServer: {
// ...
// host: hostIp,
port: PORT_ENV || 8080,
proxy: [
{
context: ['/web/api/'],
// dev
target: 'https://web-dev.xgqfrms.xyz',
// prod
// target: 'https://web-prod.xgqfrms.xyz',
},
],
},
};
module.exports = config;
refs
https://github.com/xgqfrms/set-process-env
https://github.com/xgqfrms/set-process-env/issues/5
https://www.npmjs.com/package/app-node-env
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15409327.html
未经授权禁止转载,违者必究!