Webpack DllReferencePlugin无法正常工作

我在其中一个项目上遇到了DllReferencePlugin的问题(我使用的是Webpack 1.13.2).特别是,我有3对由DllPlugin生成的清单和包文件,在主插件的插件部分,我有3个DllReferencePlugin部分:

entry: {    
  body: [
    './src/main.js',
  ],
},
...
plugins: [
...
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'commons-manifest.json'),
    }),
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'vendor-manifest.json'),
    }),
    new webpack.DllReferencePlugin({
      context: process.cwd(),
      manifest: path.join(dllPath, 'react-manifest.json'),
    }),    
]
...

当我尝试运行它时,我收到以下错误:

/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js:43
if(request && request in this.options.content) {
^

TypeError: Cannot use ‘in’ operator to search for ‘./src/main.js’ in
undefined

相同的配置对我的其他项目很有用,所以我认为这个错误与路径解析有关.我已经尝试了上下文和清单路径的相对路径,但它也不起作用.

最佳答案 问题是对于这个特定版本的Webpack(1.13.2)清单:require(path.join(dllPath,’commons-manifest.json’))应该用而不是manifest:path.join(dllPath,’commons- manifest.json的“)

点赞