webpack 在index.html里面区分环境变量
html标签里面:<% if (process.env.NODE_ENV === 'development') { %><script src="<%= BASE_URL %>libs/vue/vue.js"></script><script src="<%= BASE_URL %>libs/vue-route...
·
html标签里面:
<% if (process.env.NODE_ENV === 'development') { %>
<script src="<%= BASE_URL %>libs/vue/vue.js"></script>
<script src="<%= BASE_URL %>libs/vue-router/vue-router.js"></script>
<script src="<%= BASE_URL %>libs/vuex/vuex.js"></script>
<% } else { %>
<script src="<%= BASE_URL %>libs/vue/vue.min.js"></script>
<script src="<%= BASE_URL %>libs/vue-router/vue-router.min.js"></script>
<script src="<%= BASE_URL %>libs/vuex/vuex.min.js"></script>
<% }
%>
javascript里面:
<script>
if ('<%= process.env.NODE_ENV %>' === 'development') {
window.SITE_CONFIG['apiURL'] = '/api'; // prod_api // api请求地址
}
else {
window.SITE_CONFIG['apiURL'] = '/prod_api'; //
}
</script>
访问打包后的文件文件路径:
<script src="<%= BASE_URL %>iconfont/iconfont.js"></script>
更多推荐
已为社区贡献9条内容
所有评论(0)