Webpack DllReferencePlugin 不工作
Webpack DllReferencePlugin is not working
我的一个项目中的 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) 应该使用 manifest: require(path.join(dllPath, 'commons-manifest.json'))
而不是 manifest: path.join(dllPath, 'commons-manifest.json')
我的一个项目中的 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) 应该使用 manifest: require(path.join(dllPath, 'commons-manifest.json'))
而不是 manifest: path.join(dllPath, 'commons-manifest.json')