亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

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

正在回答

2 回答

看一下你的第8行。。。。mian、main~曾經多次敲錯的英文單詞啊

1 回復 有任何疑惑可以回復我~
#1

杭州程序員張張 提問者

.....
2017-05-14 回復 有任何疑惑可以回復我~

我也是這個問題 請問解決了嗎 我看了一下我沒有寫錯的地方啊

0 回復 有任何疑惑可以回復我~
#1

慕粉3777950

可能是你的模板index.html文件不夠干凈,<script src="<%= htmlWebpackPlugin.files.chunks.main.entry%>"></script>像這類語句,即便是注釋掉,實際上還是會去執行的,所以需要把帶有<%%>這類腳本的注釋都去掉
2017-08-05 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

Cannot read property 'entry' of undefined

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號