多入口js
webpack.config.js
module.exports = {
entry: {
app: './src/index.js',
print: './src/print.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
向 HTML 动态添加 bundle
npm install --save-dev html-webpack-plugin
webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
plugins: [
new HtmlWebpackPlugin({
title: "out Management"
})
],
};
打包前清理(引入方法与官网有些不同)
npm install clean-webpack-plugin --save-dev
webpack.config.js
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
module.exports = {
plugins: [
new CleanWebpackPlugin(),
],
};