html文件的打包:html-webpack-plugin
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
main: './src/main.js',
index: './src/index.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new HTMLWebpackPlugin({
//引用的HTML模板
template: './src/index.html',
//生成的文件名称 page文件夹下的index.html 最终生成dist/page/index.html
filename: 'page/index.html',
//title
title: 'healthy',
//引入的js文件,在入口文件中配置好
chunk: ['index']
//css文件通过在js文件中import引入,打包后就会通过link标签插入到HTML文件中
//hash == true 时,打包编译后的HTML文件引入的js、css文件带有hash
hash: true
})
]
}