Im trying to generate an index.html using HtmlWebpackPlugin() but when I try using the following configuration(for caching) I find that webpackManifest is not inserted into the page, and I get an "undefined" error. Here is my config file:
module.exports = function(env) {
return {
entry: {
main: './app/index.js',
vendor: ['moment','lodash','jquery']
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
publicPath : './'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ["vendor", "manifest"]
}),
new webpack.HashedModuleIdsPlugin(),
new WebpackChunkHash(),
new ChunkManifestPlugin({
filename: "chunk-manifest.json",
manifestVariable: "webpackManifest"
}),
new HtmlWebpackPlugin({
chunksSortMode: 'dependency',
hash : true
}),
new ScriptExtHtmlWebpackPlugin()
]
}
};
And the error:
Uncaught TypeError: Cannot read property '0' of undefined
script.src = __webpack_require__.p + window["webpackManifest"][chunkId];
reproducethe issue ,look like your configuration is fine