Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Enable minification
Browse files Browse the repository at this point in the history
  • Loading branch information
iamakulov committed Jan 30, 2018
1 parent 270dfa3 commit eeb65a6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webpack.config.js
Expand Up @@ -12,6 +12,7 @@
*/

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');

Expand Down Expand Up @@ -60,7 +61,10 @@ module.exports = {
}),
].concat(
isProduction
? []
? [
// Minimize the app code
new webpack.optimize.UglifyJsPlugin(),
]
: [
// Force writing the HTML files to disk when running in the development mode
// (otherwise, webpack-dev-server won’t serve the app)
Expand Down

1 comment on commit eeb65a6

@iamakulov
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit enables minification using UglifyJsPlugin.

UglifyJS is not the only tool that minifies the code. There’re other minifiers that could compress code better or worse – e.g. Babel Minify and Google Closure Compiler. Give them a try!

Sizes
bundle.js went down from 1.01 MB to 399 kB.

Bundle difference
Here’s the bundle before and after the commit:

// bundle.js, before minification
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
// ...
// bundle.js, after minification
!function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})}, // ...

Please sign in to comment.