Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Webpack 5 how to disable compression and left only minification

I have a webpack project with a few js files:

package.json

...
"scripts": {
   
    "dev": "webpack --config webpack.dev.js",
    "watch": "webpack --config webpack.dev.js --watch",
    "build": "webpack --config webpack.prod.js"
  },
...

webpack.prod.js

...
entry: {
        portal: `${portalDir}assets/js/portal.js`,
        branding: `${portalDir}assets/js/branding.js`,
    },
    externals: {
        jquery: 'jQuery',
    },
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname, `${portalDir}dist/js`),
        clean: true,
    },

    performance: {hints: false,},
...

portal.js

function demofunction(){console.log("demo");}
function demofunction2(){console.log("demo2");}

branding.js

function brandingfunction1(){console.log("br");}
function brandingfunction2(){console.log("br2");}

when i use the command

npm run build

this command generate the files dist/js/portal.js and dist/js/branding.js but the code it's obfuscated or something, i want a builded file like:

portal.js

function demofunction(){console.log("demo");} function demofunction2(){console.log("demo2");}

The code is only minified but the result using npm run build generate something like:

(()=>{var e={};function t(e,t){....};})

Is there any way to only minify the js code? i try using:

optimization: {
        minimize: true,
        minimizer: [new TerserPlugin({
            terserOptions: {
                compress: false,
                mangle: true,
                module: true,
            }
        })],
    },

in webpack.prod.js but it doesn't work.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!