vue项目添加自定义配置项

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

config/prod.env.js

"use strict";

module.exports = {
    NODE_ENV: '"production"',
    TITLE: '"运维系统"',
    WWW_URL: '"http://www.abc.com"',
    BASE_URL: '"http://api.abc.com/msweb"',
    UPLOAD_URL: '"http://api.abc.com/upload"',
};

config/dev.env.js

"use strict";

const merge = require("webpack-merge");
const prodEnv = require("./prod.env");

module.exports = merge(prodEnv, {
    NODE_ENV: '"development"',
    BASE_URL: '"http://api.abc.com/dev/msweb"'
});

build/build.js

process.env.NODE_ENV = "production";

const env = process.argv.splice(2)[0] || "prod";
if (env == "dev") {
    process.env.NODE_ENV = 'development';
}

......


const spinner = ora("building for " + process.env.NODE_ENV + "...");

build/webpack.prod.conf.js

const env = process.env.NODE_ENV == "production"
        ? require("../config/prod.env")
        : require("../config/dev.env");

完成以上文件代码修改后,执行命令:

发布production包:npm run build

发布development包:npm run build dev

 

转载于:https://my.oschina.net/qiongtaoli/blog/3010630

你可能感兴趣的:(javascript,python,webpack,ViewUI)