参考
官网
掘金酱
MR
const path = require('path');const rimraf = require('rimraf');const Config = require('webpack-chain');const config = new Config();const HtmlWebpackPlugin = require('html-webpack-plugin');const webpack = require('webpack');// 删除 dist 目录rimraf.sync('dirDist');config.entry('a').add('./src/test/a.js')config.entry('b').add('./src/test/b.js').end()// 模式// .mode(process.env.NODE_ENV) 等价下面.set('mode', process.env.NODE_ENV)// 出口.output.path(path.resolve(__dirname,'dirDist')).filename('[name].bundle.js');config.module .rule('css') .test(/\.css$/) .use('css') .loader('css-loader');config.devServer.host('127.0.0.1').port("8090").hot(true).contentBase("./public/index.html");config .plugin('html-plugin') .use(HtmlWebpackPlugin,[{ filename:'index.html', template:'./public/index.html' }]).end();config.plugin('define-plugin') .use(new webpack.DefinePlugin({ env:JSON.stringify(process.env) })).end();module.exports = config.toConfig();