webpack DllPlugin xxx is not defined解决办法

Neysa ·
更新时间:2024-11-10
· 652 次阅读

造成这个错误主要有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, //这里需要和DllPlugin option.name 一致 }, entry: { "lib": vendors, }, plugins: [ new webpack.DllPlugin({ path:path.resolve(__dirname,'../dist/manifest.json'), name: dllName, context: __dirname, //上下文必填 }), new CleanWebpackPlugin([`./dist/*.dll.js`,`./dist/*.json`], { root: path.resolve(__dirname, "../") }), ] }

webpack.config.js   

new webpack.DllReferencePlugin({ context: __dirname, //这个上下文对应DllPlugin manifest: require('../dist/manifest.json')} ), new AddAssetHtmlPlugin( [ { filepath: "./dist/*.dll.js", //将生成的dll文件加入到index.html中 }, ] ),



defined NOT IS webpack

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章