当前位置: 首页 > 后端技术 > Node.js

webpack配置界面路径

时间:2023-04-03 18:23:00 Node.js

例如添加newwebpack.DefinePlugin({'process.env.NODE_ENV':JSON.stringify('production'),IS_SIGN:JSON.stringify('prodsign')}),则可以根据IS_SIGN判断/*globalIS_SIGN:true*/console.log(IS_SIGN);switch(IS_SIGN){case'localsign':API='http://192.168.1.xx:9090/';WEB='http://192.168.1.xx:8080/';休息;case'testsign':API='http://192.168.1.xx:9090/';WEB='http://heiyanquan.github.com/test.html';休息;case'prodsign':API='http://192.168.1.xx:9090/';WEB='http://heiyanquan.github.com/index.html';break;}需要注意的是,如果你在webpack中集成了ESLint,那么,因为ESLint会检测未定义的变量(ESLint在使用全局变量时需要使用window.xxxxx),所以需要全局注释语句(/globalIS_PRODUCTION:true/)IS_SIGN是避免警告的全局变量。