Posting answer to my own question. Thanks @str for helping out.

I was using different versions of Uglify JS, not sure if that was the problem.

So I tried installing webpack version 4 which is now in beta so I had to do install webpack@next . Also, webpack-cli is now its own package so I had to install it too. Earlier, it was bundled with webpack itself.

After installing both webpack@next & webpack-cli , I changed my webpack.config,js to look like -

webpack.config,js

const path = require("path"); const webpack = require("webpack"); const config = { entry: "./app.js", output: { path: path.resolve(__dirname, "dist"), filename: "bundle.js" } }; module.exports = config;

And ran the following to generate bundle with TreeShaking

webpack --optimize-minimize --mode production

The complete code is available at https://github.com/deadcoder0904/webpack-treeshake

Checkout my other answer to TreeShake with Lodash which does all the treeshaking