![9f0a308678bc4248f0a73dbed48ad1b9.png](https://i-blog.csdnimg.cn/blog_migrate/0f45fd9055abaa2f5287bedcb4c71a57.png)
本文衔接上一篇文章:
不睡觉的怪叔叔:webpack的插件zhuanlan.zhihu.com![f66eed66325f4bc523826f03de5b8c21.png](https://i-blog.csdnimg.cn/blog_migrate/fc71a6e11c38b32c38be33d21a8712c9.png)
一、多入口打包的配置
webpack支持多入口的打包操作吗?答案是肯定的!
让我们修改webpack.config.js:
webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); // 导入HtmlWebpackPlugin
const CleanWebpackPlugin = require('clean-webpack-plugin'); // 导入CleanWebpackPlugin
module.exports = {
mode: 'development',
entry: {
main: './src/index.js',
sub: './src/index.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /.(png|svg|jpg|gif$)/, // 文件后缀名匹配通配符
use: [{
loader: 'url-loader', // 使用的lo