1. the document introduction inlet
: As long as introduced will be packed
cnpm i jquey -S
index.js
import $ from 'jquey';
$('ul li:last-child').css('background','pink')
2.Webpack.ProvidePlugin // recommended the introduction of this
- Automatically load the module, without having to use the import or require
- If the load module is not used, it will not be packaged
- Loaded modules as a global module, can be used in the global (and import documents can only be used where the entrance to load the file)
const webpack = require('webpack'); //引入热更新插件
module.exports = {
entry:'./src/js/index.js', //入口起点
output:{ //输出
path:path.resolve(__dirname,'dist'), //目标输出目录的绝对路径
filename:'js/boundle.js' //输出文件的文件名
},
plugins:[
new webpack.ProvidePlugin({
$:'jquery' //引入第三方库
}),
],
module:{
rules:[//对象
//这里面放的就是一个个的loader,每一个loader要放在一个对象里,这里面的内容不能变,从后往前解析
{
},
}
}
-S placed in a production environment, not only the development environment and the on-line environment is also required
cnpm i jquey -S // jqeury as an example