webpack.config.js====插件html-webpack-plugin

1. 安装

cnpm install html-webpack-plugin --save-dev

2. webpack.config.js中使用

const htmlWebpackPlugin = require('html-webpack-plugin');

 配置多个html页面

 /*
    * 配置多个入口文件
    * */
    entry: {
        index: './src/default/js/index.js',
        about: './src//about/js/index.js',
        course: './src/course/js/index.js'
    },
  /*
        * 配置html-webpack-plugin插件(配置多个html文件)
        * template:模板路径
        * filename:输出文件,可以是路径
        * minify.removeComments:打包后是否删除参数
        * minify.collapseWhitespace:打包后是否删除空格(压缩)
        * hash
        * chunks:包含的文件数组
        * */
        new htmlWebpackPlugin({
            template: './src/index.html',
            filename: 'index.html',
            minify: {
                collapseWhitespace: true
            },
            hash: true,
            chunks: ['index']
        }),
        new htmlWebpackPlugin({
            template: './src/about/index.html',
            filename: 'about/index.html',
            minify: {
                collapseWhitespace: true
            },
            hash: true,
            chunks: ['about']
        }),
        new htmlWebpackPlugin({
            template: './src/course/index.html',
            //编译后路径是:dist/course/index.html
            filename: 'course/index.html',
            minify: {
                collapseWhitespace: true
            },
            hash: true,
            chunks: ['course']
        }),

 

转载于:https://www.cnblogs.com/songxia/p/10295765.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值