> For the complete documentation index, see [llms.txt](https://sugar-at.gitbook.io/blog-article/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sugar-at.gitbook.io/blog-article/webpack/jquery.md).

# 8. 引入jQuery

## 1. 本地文件引入

### 配置

```javascript
const webpack=require('webpack');

module.exports={
    resolve:{
        alias:{
            //绝对路径
            jQuery:path.resolve(__dirname,'src/js/libs/jquery.min.js')
        }
    },
    plugins:[
        new webpack.ProvidePlugin({
            $:"jQuery"
        })
    ]
}
```

### 使用

index.js

```javascript
$(document).ready(function() {
    console.log("success");
})
```

## 2. 通过npm引入

### 安装

```
npm install  jquery --save-dev
```

### 使用

index.js

```javascript
import $ from 'jquery'

$(document).ready(function() {
    console.log("success");
})
```
