Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Can't keep class names using uglifyjs-webpack-plugin with "mode": "production" #5

@lgarron

Description

@lgarron

As soon as I set module.exports.mode = "production", class names are mangled.

Some references:
https://webpack.js.org/plugins/uglifyjs-webpack-plugin/
https://github.com/webpack-contrib/uglifyjs-webpack-plugin

Absolutely nothing works to keep the class names, including this overkill config:

plugins: [
  new UglifyJSPlugin({
    sourceMap: true,
    uglifyOptions: {
      keep_classnames: true,
      "mangle": {
        keep_classnames: true
      },
      "compress": {
        keep_classnames: true
      }
    }
  })
],

Or this one:

optimization: {
  minimizer: [
    new UglifyJSPlugin({
      sourceMap: true,
      uglifyOptions: {
        keep_classnames: true,
        "mangle": {
          keep_classnames: true
        },
        "compress": {
          keep_classnames: true
        }
      }
    })
  ]
},

I know that the config is being parsed properly, because I get errors if I place keep_classnames directly in the UglifyJSPlugin config object or change keep_classnames into a typo anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions