一、HtmlWebpackPlugin使用:
npm install html-webpack-plugin --save-dev
解释:这个插件是简化创建生成html(h5)文件用的,如果你引入的文件带有hash值的话,这个尤为的有用,不需要手动去更改引入的文件名!
默认生成的是index.html,基本用法为:
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpackConfig = {
entry: 'index.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
plugins: [new HtmlWebpackPlugin()]
};
js通过script的标签引入到body中!
如果你使用了ExtractTextPlugin来提取css,将通过link在head中引入!
一般配置:
title: 用于生成的HTML文档的标题,也就是html,head中`
ceshi`filename: 生成的文件名,default index.html
template: 模版(填写相对路径,与配置文件的相对路径,例如:'./index.html'
hash: 增加hash值,使每次生成的都是唯一的不重复的
二、ExtractTe