* forward to: http://blog.csdn.net/fungleo/article/details/54574049
The first step is to set a different interface address. First, we find the following file separately:/config/Dev.env.js/config/Prod.env.jsIn fact, these two files are files that set different parameters for the production environment and the publishing environment. We open the Dev.en.js file. The code is as follows:varMerge = require (' Webpack-merge ')varProdenv = require ('./prod.env ')) Module.exports=Merge (prodenv, {node_env:' "Development" '})OK, let's add an entry below the NODE_ENV code as follows:varMerge = require (' Webpack-merge ')varProdenv = require ('./prod.env ')) Module.exports=Merge (prodenv, {node_env:' "Development" ', Api_root:' "//192.168.1.8/api" '})then, we edit the Prod.env.js file, Module.exports={node_env:' "Production" ', Api_root:' "//www.baidu.com/api" '}good. The paths we set separately are already there. Here is the question of how to invoke it. In the second part, call the set parameters in the code as an example of our previous demo code. Please adjust your own project according to your own situation. The following files and codes are for informational purposes only. We open src/config/api.js file, the code that starts with the original//Configure API Interface addressvarroot = ' Https://cnodejs.org/api/v1 'modified to//Configure API Interface addressvarRoot =Process.env.API_ROOTthen we finished our configuration work. Finally, restarting the project will enable the newly configured interface address to take effect. After this configuration, we are running npm run dev1, the test interface is what runs. And we're running NPM run build1when packaging the project, the packaging is the official interface of the server, we do not have to tune to get it. Have a good time!
VUE uses Webpack to configure different interface addresses for production environments and release environments