gezilan 2019-07-01
1. 从CDN引入jQuery
```javascript
<script
src="https://code.jquery.com/jquery-3.1.0.js"
integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk="
crossorigin="anonymous">
</script>
```
2. webpack.config.js配置
```javascript
// ....
externals: {
jquery: 'jQuery'
}
```
3. 这样就解决了那些不需要改动的依赖
具有外部依赖(external dependency)的 bundle 可以在各种模块上下文(module context)中使用
```javascript
import $ from 'jquery';
$('.my-element').animate(/* ... */);
```对于通过externals设置的外部依赖,可以通过以下几种方式来进行访问root 全局访问 commonJS模块访问 AMD模块访问