【1】不采用腳手架的config文件夾中的配置文件
【2】在static文件夾下,自定義一個congfig.js文件
// 配置開發環境下服務器地址 window.Glod = { pmsApiUrl: 'https://xxxxxx', pmsApiPort: '29999' } // 配置測試環境下服務器地址 window.Glot = { pmsApiUrl: 'https://xxxxxx', pmsApiPort: '9999' } // 配置生產環境下服務器地址 window.Glop = { pmsApiUrl: 'https://xxxxxx', pmsApiPort: '9999' }
【3】在index.html中引入
<script type="text/javascript"> document.write("<script src=<%= htmlWebpackPlugin.options.path %>/config.js?v=" + new Date().getTime() + "><\/script>"); </script>
相關博文:
https://blog.csdn.net/Amy_cloud/article/details/91873507