,四webpack打包html资源

使用html-webpack-plugin插件,可以在打包后自动生成一个index.html文件,这个index.html文件里会把打包后的静态资源引入。

相关配置如下面所受

const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    entry: "./src/main.js",
    output:{
        filename: 'index.js',
        path:path.resolve(__dirname, 'build')
    },
    module:{
    },
    plugins:[
        new htmlWebpackPlugin({
            template:"./src/index.html"
        })
    ],
    mode:'development'
}

其中template为指定打包的html使用的模板。