fix: Webpack has been initialized using a configuration object that does not match the API schema

An unhandled error has occurred inside Forge:
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.plugins[6] should be one of these:
   object { apply, … } | function
   -> Plugin of type object or instanceof Function.
   Details:
    * configuration.plugins[6] should be an object:
      object { apply, … }
      -> Plugin instance.
    * configuration.plugins[6] should be an instance of function.
      -> Function acting as plugin.
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.plugins[6] should be one of these:
   object { apply, … } | function
   -> Plugin of type object or instanceof Function.
   Details:
    * configuration.plugins[6] should be an object:
      object { apply, … }
      -> Plugin instance.
    * configuration.plugins[6] should be an instance of function.
      -> Function acting as plugin.

This is because there is an undefined in the plugins list

exports.renderer [
  DefinePlugin {
    definitions: { 'process.env.NODE_ENV': '"development"' }
  },
  CspHtmlWebpackPlugin {
    cspPluginPolicy: {
      'base-uri': [Array],
      'object-src': [Array],
      'script-src': [Array],
      'style-src': [Array],
      'frame-src': [Array],
      'worker-src': [Array]
    },
    opts: {
      enabled: true,
      hashingMethod: 'sha256',
      hashEnabled: [Object],
      nonceEnabled: [Object],
      processFn: [Function: defaultProcessFn]
    }
  },
  WebpackBarPlugin {
    profile: false,
    handler: [Function (anonymous)],
    modulesCount: 5000,
    dependenciesCount: 10000,
    showEntries: true,
    showModules: true,
    showDependencies: true,
    showActiveModules: true,
    percentBy: undefined,
    options: {
      name: 'webpack',
      color: 'green',
      reporters: [Array],
      reporter: null
    },
    reporters: [ FancyReporter {} ]
  },
  undefined
]
This commit is contained in:
林一二 2021-08-07 19:57:26 +08:00
parent e583557eac
commit e8b36edd1c

View file

@ -47,7 +47,7 @@ exports.main = _.compact([
new WebpackBar(),
]);
exports.renderer = [
exports.renderer = _.compact([
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${process.env.NODE_ENV ?? 'production'}"`,
// global: {},
@ -72,4 +72,4 @@ exports.renderer = [
? // eslint-disable-next-line @typescript-eslint/no-unsafe-call
new BundleAnalyzerPlugin({ generateStatsFile: true, analyzerMode: 'disabled', statsFilename: '../../out/webpack-stats-renderer.json' })
: undefined,
];
]);