// config/cdn.js
const cdn = {
css: [// 'https://cdn.jsdelivr.net/npm/vant@2.8/lib/index.css'],
js: [
'https://cdn.bootcss.com/vue/2.5.2/vue.min.js',
'https://cdn.bootcss.com/vue-router/3.0.1/vue-router.min.js',
'https://cdn.bootcss.com/vuex/3.0.1/vuex.min.js'
]
}
module.exports = cdn
// webpack.config.js
plugins: [
new HtmlWebpackPlugin(Object.assign({
filename: 'index.html',
template: 'index.html',
inject: true
}, config.cdn))
]
<!--index.html-->
<body>
<div id="app">
<!-- shell -->
</div>
<script src="./static/js/axios.min.js"></script>
<% for (var i in htmlWebpackPlugin.options.js&&htmlWebpackPlugin.options.js) { %>
<script src="<%= htmlWebpackPlugin.options.js[i] %>"></script>
<% } %>
<!-- built files will be auto injected -->
</body>