webpack之插件使用

1.安装html_webpack_plugin插件

cnpm i -D html-webpack-plugin

2.在web.config.js里面配置引用的插件

const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
module.exports={//node.js语法导出一个对象
    entry:'./src/app.js',
    output:{
        path:path.resolve(__dirname,'dist'),//绝对路径
        filename:'main.js',
    },
    plugins:[
        new htmlWebpackPlugin({
            filename:'aa.html',//指定生成的文件名字
            template:'src/index.html',//指定模版
        })
    ]
}

3.cnpm run dev 运行

posted on 2018-01-15 17:51  running-fly  阅读(77)  评论(0)    收藏  举报

导航