From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Prepare code for production

Prepare code for production

From the course: Learning webpack 4

Start my 1-month free trial

Prepare code for production

- [Instructor] Once our code is ready to go to production, we want to make sure that it is as small as possible. So one way that we can do this is by minifying it and making it production ready. So a really nice tool for this is a webpack plugin called the Uglify JS webpack plugin. And we can use this to make these files as small as possible by minifying them. The first thing I want to do is NPM install the Uglify JS webpack plugin. Save dev. Once this is installed we can add it to our config. So let's go ahead and add Uglify JS plugin. And then we'll require it. Perfect. Within our config object we're going to add this here. So we'll say optimization. We will add a key called minimizer. So we'll just add new Uglify JS plugin. And we will create this. Now I can go ahead and run this. NPM run build. And we should see a couple things happen. So first of all, we should see that our index HTML has been generated using the HTML webpack plugin. Also should see that the main JS file has been…

Contents