本節最后的問題
ERROR in Template execution failed: TypeError: Cannot read property 'entry' of undefined
ERROR in ? TypeError: Cannot read property 'entry' of undefined
<%= compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %> ?取不到entry嗎? 為什么?這里有點懵
2017-02-21
你的plugins里chunks少了main
2017-03-12
// 解決了hash問題,以及生成html文件,壓縮html,自動引入帶hash的js文件。
var htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'main':'./src/script/main.js',
'a':'./src/script/a.js',
'b':'./src/script/b.js',
'c':'./src/script/c.js'
},
output: {
path: './dist/',
filename: 'js/[name]-[chunkhash].js',
// 此key上線時需要,為絕對路徑。
publicPath:'http://www.yangshaofeng.cn/'
},
plugins: [
new htmlWebpackPlugin({
filename:'a.html',
template:'index.html',
title:'this is a.html',
inject:'body',
minify:{
removeComments:true,
collapseWhitespace:true
},
excludeChunks:['b','c']
}),
new htmlWebpackPlugin({
filename:'b.html',
template:'index.html',
title:'this is b.html',
inject:'body',
minify:{
removeComments:true,
collapseWhitespace:true
},
excludeChunks:['main','a','c']
}),
new htmlWebpackPlugin({
filename:'c.html',
template:'index.html',
title:'this is c.html',
inject:'body',
minify:{
removeComments:true,
collapseWhitespace:true
},
excludeChunks:['main','a','b']
})
]
}
求助
2017-02-21
更新下node