1. Install the jquery library

cnpm install --save  jquery expose-loader
Copy the code

2. Configure the configuration in webpack.config.js

Jquery library is a ProvidePlugin for webPack, so you can configure ProvidePlugin directly without importing/requiring this module

Configuration of 3.

new webpack.ProvidePlugin({     $: 'jquery',     JQuery: 'jQuery'}), // Note: when you encounter or handle jQuery or $, you will automatically load the jQuery libraryCopy the code

4. Usage

Using the jquery library in index.js, after importing the file, you can use it directly

// Introduce: require("expose-loader? $! jquery"); // import $from 'jquery';Copy the code