5.创建项目文件,如下图所示:
6.webpack主要用到三种插件,插件均通过cnpm install 插件名
(1)html-webpack-plugin
new htmlWebpackPlugin({
template: 'index.html',
filename: 'index.html',
inject: false,
minify: { //压缩Html
removeComments: true, //除去注释
collapseWhitespace: true //除去空格
}
})
(2)copy-webpack-plugin
new copyWebpackPlugin([
{ from: 'app/views/**' },
{ from: 'app/resource/**' },
{ from: 'app/images/**' }
])
(3)clean-webpack-plugin
new cleanWebpackPlugin(['build'], {})