构建webpack供应商dll并获取
Uncaught ReferenceError: vendors_9a2b8ee29a9e8dcdc486b49a360b9763 is not defined
编译后的代码以
形式出现module.exports = vendors_9a2b8ee29a9e8dcdc486b49a360b9763;
//////////////////
// WEBPACK FOOTER
// external "vendors_9a2b8ee29a9e8dcdc486b49a360b9763"
// module id = 2
// module chunks = 0
它缺少声明和定位类似
的内容var angular = __webpack_require__(2)
module.exports = (__webpack_require__(3))(1)
我不知道为什么会这样,我已经尽力了。这是我的webpack配置的插件:
plugins: [
new webpack.DllReferencePlugin({
context: '.',
manifest: require('./src/tmp/vendors-manifest.json')
}),
],
这是我的dll配置:
var webpack = require('webpack');
var packageJSON = require('./package.json');
var path = require('path');
module.exports = {
entry: {
vendors: Object.keys(packageJSON.devDependencies),
},
output: {
path: path.join(__dirname, 'src/tmp'),
filename: 'vendors.bundle.js',
library: 'vendors_[hash]'
},
plugins: [
new webpack.DllPlugin({
path: 'src/tmp/[name]-manifest.json',
name: 'vendors_[hash]'
}),
]
};
index.html导入:
<script type="text/javascript" src="/src/tmp/vendors.bundle.js"></script>
<script type="text/javascript" src="/dist/js/app.js"></script>
任何想法都将不胜感激! 提前谢谢!
答案 0 :(得分:3)
我遇到了同样的问题。我不得不添加&#34;库&#34;输出部分的选项,具有相同的名称。
/python-package
答案 1 :(得分:0)
我遇到了这个问题。 它通过更改上下文来解决。
plugins: [
new webpack.DllReferencePlugin({
context: path.join(__dirname, 'src/tmp'),
manifest: require('./src/tmp/vendors-manifest.json')
})]
答案 2 :(得分:-1)
修改你的dll配置文件,并将你的代码设置为
new webpack.DllPlugin({
path: 'path.join(__dirname, 'src/tmp/manifest.json')',
name: 'vendors_[hash]'
}),
并在您的配置文件中修改DllReferencePlugin到此
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require(path.join(__dirname, 'src/tmp/manifest.json')),
name: 'vendors_9a2b8ee29a9e8dcdc486b49a360b9763'
}),
],