webpack html-webpack-plugin 遍历

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
  <%= htmlWebpackPlugin.options.date %>
  <% for(var key in htmlWebpackPlugin.files) { %>
    <%= key %> : <%= JSON.stringify(htmlWebpackPlugin.files[key]) %>
  <% } %>

  <%= htmlWebpackPlugin.options.date %>

  <% for(var key in htmlWebpackPlugin.options) { %>
    <%= key %> : <%= JSON.stringify(htmlWebpackPlugin.options[key]) %>
  <% } %>
</body>
</html>

打包后的结果

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>webpack is very good</title>
<script type="text/javascript" src="js/main-df735bd75d7abb5252d2.js"></script><script type="text/javascript" src="js/a-c21ac76689ad2a5125c6.js"></script></head>
<body>
Wed Apr 04 2018 09:46:54 GMT+0800 (中国标准时间)

publicPath : ""

chunks : {"main":{"size":23,"entry":"js/main-df735bd75d7abb5252d2.js","hash":"df735bd75d7abb5252d2","css":[]},"a":{"size":22,"entry":"js/a-c21ac76689ad2a5125c6.js","hash":"c21ac76689ad2a5125c6","css":[]}}

js : ["js/main-df735bd75d7abb5252d2.js","js/a-c21ac76689ad2a5125c6.js"]

css : []

manifest :

Wed Apr 04 2018 09:46:54 GMT+0800 (中国标准时间)


template : "C:\\Users\\Administrator\\Desktop\\webpackdemo\\node_modules\\html-webpack-plugin\\lib\\loader.js!C:\\Users\\Administrator\\Desktop\\webpackdemo\\index.html"

templateParameters :

filename : "index.html"

hash : false

inject : "head"

compile : true

favicon : false

minify : false

cache : true

showErrors : true

chunks : "all"

excludeChunks : []

chunksSortMode : "auto"

meta : {}

title : "webpack is very good"

xhtml : false

date : "2018-04-04T01:46:54.014Z"

</body>
</html>

 

posted @ 2018-04-04 09:50  松歌  阅读(497)  评论(0编辑  收藏  举报