预先准备,设定 HtmlWebpackPlugin,清理 /dist 文件夹
- npm install --save-dev html-webpack-plugin
- npm install clean-webpack-plugin --save-dev
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
print: './src/js/print.js'
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'Output Management'
})
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
};
Manifest
- webpack及其插件通过manifest“知道”应该哪些文件生成