webpack DllPlugin xxx is not defined解决办法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

webpack DllPlugin xxx is not defined解决办法

ZoeLee   2020-05-17 我要评论

造成这个错误主要有3个可能的原因:

  • context上下文不一致
  • library和name 不一致
  • 生成的dll文件没加入到html文件中

dll.config.js

module.exports = {
  mode:"production",
  output: {
    path:path.resolve(__dirname, '..https://img.qb5200.com/download-x/dist'),
    filename: '[name].dll.js',
    library: dllName, //这里需要和DllPlugin option.name 一致
  },
  entry: {
    "lib": vendors,
  },
  plugins: [
    new webpack.DllPlugin({
      path:path.resolve(__dirname,'..https://img.qb5200.com/download-x/dist/manifest.json'),
      name: dllName,
      context: __dirname, //上下文必填
    }),
    new CleanWebpackPlugin([`.https://img.qb5200.com/download-x/dist/*.dll.js`,`.https://img.qb5200.com/download-x/dist/*.json`], { root: path.resolve(__dirname, "../") }),
  ]
 }

webpack.config.js   

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们