2017-02-26 36 views
4

我有與DllReferencePlugin我的項目的一個問題(我使用的WebPack 1.13.2)。特別是,我有3對由產生DllPlugin艙單和捆綁文件,並在我的插件爲主要組部分我有3個DllReferencePlugin部分:的WebPack 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

相同的配置適用於我的其他項目,所以我認爲這個錯誤與路徑解析有關。我已經嘗試了上下文和清單路徑的相對路徑,但它也不起作用。

回答

1

問題是,對於這個特定版本的Webpack(1.13.2)應該使用manifest: require(path.join(dllPath, 'commons-manifest.json'))而不是manifest: path.join(dllPath, 'commons-manifest.json')