webpack html-webpack-plugin

  

npm init创建包。json

npm安装——save-dev html-webpack-plugin

生成包。json

 


创建测试。js

 var  HtmlWebpackPlugin =,要求(& # 39;html-webpack-plugin& # 39;);
  var  path =,要求(& # 39;path & # 39;);
  
  var  webpackConfig =, {
  条目:& # 39;。/. js # 39;
  输出:{
  路径:path.resolve (__dirname, & # 39;。/dist # 39;),
  文件名:& # 39;index_bundle.js& # 39;
  },
  插件:[new  HtmlWebpackPlugin ({
  标题:“test  file"
  使变小:假
  }))
  };
  
  时间=module.exports  webpackConfig; 


执行webpack——配置webpack.config。js

在dist中生成index . html, index_bundle.js

索引。html如下

& lt; ! DOCTYPE  html>   & lt; html>   & lt;才能head>   ,,,& lt; meta  charset=癠TF-8"比;   ,,,& lt; title> test  file   & lt;才能/head>   & lt;才能body>   & lt;才能script 类型=拔谋?javascript" https://www.yisu.com/zixun/, src=" index_bundle.js ">   




webpack html-webpack-plugin