webpack DllPlugin xxx is not defined解决办法
造成这个错误主要有3个可能的原因:
- context上下文不一致
- library和name不一致
- 生成的dll文件没加入到html文件中
dll.config.js
module.exports={ mode:"production", output:{ path:path.resolve(__dirname,'../dist'), filename:'[name].dll.js', library:dllName,//这里需要和DllPluginoption.name一致 }, entry:{ "lib":vendors, }, plugins:[ newwebpack.DllPlugin({ path:path.resolve(__dirname,'../dist/manifest.json'), name:dllName, context:__dirname,//上下文必填 }), newCleanWebpackPlugin([`./dist/*.dll.js`,`./dist/*.json`],{root:path.resolve(__dirname,"../")}), ] }
webpack.config.js
newwebpack.DllReferencePlugin({ context:__dirname,//这个上下文对应DllPlugin manifest:require('../dist/manifest.json')} ), newAddAssetHtmlPlugin( [ { filepath:"./dist/*.dll.js",//将生成的dll文件加入到index.html中 }, ] ),
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。