解决webpack DllPlugin xxx is not defined错误的方法

导致此错误的主要原因有三个:1. context上下文不一致;2. library和name不一致;3. 生成的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':
  }
};

确保以上配置正确,可以避免此错误。

pdf 文件大小:21.22KB