1

I'm using webpack for an internal project. The project is set to be minified with TerserPlugin. The project also uses paper js library to deal with some SVG transformations. The issue I have is when I build the project for production, all paper usages are minified as well. I use the following configuration in webpack config plugins:

    new TerserPlugin({
        minify: TerserPlugin.terserMinify,
        terserOptions: {
            mangle: {
                properties: {
                    regex: /^[^_]/,
                    reserved: ['HttpRequest', 'EditorContainer', 'Color', 'paper']
                },
                reserved: ['paper']
            }
        }
    })

In the project I have the following code:

paper.setup(new paper.Size(this.canvas.width, this.canvas.height));

In the production build I get the following minified code:

Le().sC(new(Le().yg)(this.canvas.width,this.canvas.height))

At runtime I get the Le().yg is not a constructor error. Is it possible to configure Terser to leave all paper related code unchanged and only mangle internal properties, functions etc?

Andrei
  • 367
  • 5
  • 18

0 Answers0