Webpack学习(二)

5.创建项目文件,如下图所示:

Webpack学习(二)_第1张图片

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'], {})

你可能感兴趣的:(插件,webpack,前端自动化工具)