重温webpack---管理输出
Posted sophia
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了重温webpack---管理输出相关的知识,希望对你有一定的参考价值。
1、输出多个 bundle
dist/index.html
webpack.config.js
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\')
}
};
3、清理 /dist 文件夹
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/print.js\'
},
plugins: [
+ new CleanWebpackPlugin([\'dist\']),
new HtmlWebpackPlugin({
title: \'Output Management\'
})
],
output: {
filename: \'[name].bundle.js\',
path: path.resolve(__dirname, \'dist\')
}
};
看了一下githup上的写法,现在新版本的clean-webpack-plugin引入已经改为const
里面参数去掉即可
new CleanWebpackPlugin()
以上是关于重温webpack---管理输出的主要内容,如果未能解决你的问题,请参考以下文章