Cannot read property 'entry' of undefined
const path=require("path"); var htmlWebpackPlugin=require("html-webpack-plugin"); module.exports = { // configuration // entry:'./src/script/main.js', // 单个string // entry:['./src/script/main.js','./src/script/a.js'], // 数组,多个string entry:{ mian:'./src/script/main.js', a:'./src/script/a.js', b:'./src/script/b.js', c:'./src/script/c.js' }, output:{ path:path.join(__dirname,"dist"), // 打包目录 filename:'js/[name]-[chunkhash].bundle.js', // js打包后的文件 publicPath:'http://www.iVue.com/' // 占位符 线上地址 }, plugins:[ new htmlWebpackPlugin({ // 调用一次插件生成单页面 template:'index.html', filename:'a-[hash].html', // index.[hash].html inject:'head',// false title:'a webpack is awesome', date:new Date(), minify:{ // 压缩html文件 removeComments:true, // 删除html注释 collapseInlineTagWhiteSpace:true // 删除空格 } }), new htmlWebpackPlugin({ // 调用多次生成多页面 template:'index.html', filename:'b-[hash].html', // index.[hash].html inject:'head',// false title:'b webpack is awesome', date:new Date(), minify:{ // 压缩html文件 removeComments:true, // 删除html注释 collapseInlineTagWhiteSpace:true // 删除空格 } }), new htmlWebpackPlugin({ // 调用多次生成多页面 template:'index.html', filename:'c-[hash].html', // index.[hash].html inject:'head',// false title:'c webpack is awesome', date:new Date(), minify:{ // 压缩html文件 removeComments:true, // 删除html注释 collapseInlineTagWhiteSpace:true // 删除空格 } }) ] };
<head> <title><%= htmlWebpackPlugin.options.title%></title> <!--绑定title--> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="<%= htmlWebpackPlugin.files.chunks.main.entry%>"></script> </head>
我在打包的时候,一直报错的语句
<%= htmlWebpackPlugin.files.chunks.main.entry%>
错误提示:
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined ERROR in TypeError: Cannot read property 'entry' of undefined - index.html:17172 E:/Test/webpack/webpack-framework/index.html:17172:46