Dllplugin XXX is not defined solution

Time:2020-10-9

There are three possible reasons for this error

  1. The context context is inconsistent
  2. Library and name are inconsistent
  3. The generated DLL file is not added to the HTML file
dll.config.js
module.exports = {
    mode:"production",
    output: {
        path:path.resolve(__dirname, '../dist'),
        filename: '[name].dll.js',
        Library: dllname, // and dllplugin are required here option.name  agreement
    },
    entry: {
        "lib": vendors,
    },
    plugins: [
        new webpack.DllPlugin({
            path:path.resolve(__dirname,'../dist/manifest.json'),
            name: dllName,
            context: __ Dirname, // context is required
        }),
        new CleanWebpackPlugin([`./dist/*.dll.js`,`./dist/*.json`], { root: path.resolve(__dirname, "../") }),
    ]
  }
webpack.config.js   
 new webpack.DllReferencePlugin({
      context: __ Dirname, // this context corresponds to dllplugin
      manifest: require('../dist/manifest.json')}
      ),
      new AddAssetHtmlPlugin( 
        [
            {
                filepath: "./dist/*. dll.js ", // add the generated DLL file to index.html in
            },
        ]
    ),