1.主要配置如下:
const assetsCDN = {
// webpack build externals
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
axios: 'axios'
},
css: [],
// https://unpkg.com/browse/vue@2.6.10/
js: [
'//cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js',
'//cdn.jsdelivr.net/npm/vue-router@3.1.3/dist/vue-router.min.js',
'//cdn.jsdelivr.net/npm/vuex@3.1.1/dist/vuex.min.js',
'//cdn.jsdelivr.net/npm/axios@0.21.1/dist/axios.min.js'
]
}
configureWebpack: {
externals: assetsCDN.externals
},
chainWebpack: config => {
config.plugin('html').tap(args => {
args[0].cdn = assetsCDN
return args
})
},
完整的vue.config.json文件如下
const path = require('path')
const webpack = require('webpack')
const GitRe