1.在vue.config.js中使用chainWebpack添加externals配置
module.exports = {
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// #region 忽略生成环境打包的文件
var externals = {
'vue': 'Vue',
'axios': 'axios',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'echarts': 'echarts'
}
config.externals(externals)
// 在html文件中引入相关CDN
const cdn = {
css: [
// element-ui css
'https://cdn.bootcss.com/element-ui/2.13.0/theme-chalk/index.css'
],
js: [
// vue
'https://cdn.staticfile.org/