防止将某些 import 的包打包到 bundle 中,而是在运行时再去从外部获取这些扩展依赖
例如,从 CDN 引入 jQuery,而不是把它打包:
//index.html
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
//vue.config.js
configureWebpack: {
name: name,
resolve: {
alias: {
'@': resolve('src')
}
},
//表示jquery不需要打包
externals: {
jquery: 'jQuery',
},
},