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
2017-05-14
看一下你的第8行。。。。mian、main~曾經多次敲錯的英文單詞啊
2017-06-29
我也是這個問題 請問解決了嗎 我看了一下我沒有寫錯的地方啊