webpack管理输出
程序员文章站
2022-03-18 16:02:44
管理html的bundle依赖 html webpack plugin可以自动给html添加bundle文件 清理dist文件夹 ......
管理html的bundle依赖
html-webpack-plugin可以自动给html添加bundle文件
npm install --save-dev html-webpack-plugin const path = require('path'); + const htmlwebpackplugin = require('html-webpack-plugin'); module.exports = { entry: { app: './src/index.js', print: './src/print.js' }, + plugins: [ + new htmlwebpackplugin({ + title: 'output management' + }) + ], output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') } };
清理dist文件夹
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/print.js' }, plugins: [ + new cleanwebpackplugin(['dist']), new htmlwebpackplugin({ title: 'output management' }) ], output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') } };