Is it possible to prohibit certain symbols when distorting properties? / mangle

46 Views Asked by At

I get properties starting with _ and $ (_, $, _a, $a, ...), which leads to an error due to these characters being reserved by Vue.

Is there a way to ban certain characters? I didn't find anything about this in the documentation..

My Setup:

optimization: {
    minimize: true,
    minimizer: [
        new TerserPlugin({
            minify: TerserPlugin.uglifyJsMinify,
            terserOptions: {
                mangle: {
                    properties: {
                        regex: /^m_/
                    }
                },
            },
        }),
    ],
},
1

There are 1 best solutions below

0
Андреслав Козлов On

Found a temporary solution to the problem using the nth_identifier assignment (doesn't work with uglifyJsMinify)

module.exports = (env, argv) => ({
  optimization: {
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          mangle: {
            properties: {
              regex: /^m_/,
              nth_identifier,
            }
          }
        }
      })
    ]
  }
})

What my nth_identifier looks like: gist.github.com/Andreslav