From f7ac0f84e1135ce893be930da6d935216dac13d3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2017 10:51:26 +0100 Subject: [PATCH] Client: add optimize plugin --- client/config/webpack.prod.js | 12 ++++++++++++ client/package.json | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js index 51b8a8855..6d65fcb37 100644 --- a/client/config/webpack.prod.js +++ b/client/config/webpack.prod.js @@ -12,6 +12,7 @@ const commonConfig = require('./webpack.common.js') // the settings that are com const DefinePlugin = require('webpack/lib/DefinePlugin') const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') +const OptimizeJsPlugin = require('optimize-js-plugin') const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin') const WebpackMd5Hash = require('webpack-md5-hash') @@ -98,6 +99,17 @@ module.exports = function (env) { */ new WebpackMd5Hash(), + /** + * Webpack plugin to optimize a JavaScript file for faster initial load + * by wrapping eagerly-invoked functions. + * + * See: https://github.com/vigneshshanmugam/optimize-js-plugin + */ + + new OptimizeJsPlugin({ + sourceMap: false + }), + /** * Plugin: DedupePlugin * Description: Prevents the inclusion of duplicate code into your bundle diff --git a/client/package.json b/client/package.json index f4835590e..1a04be5bc 100644 --- a/client/package.json +++ b/client/package.json @@ -53,13 +53,14 @@ "ie-shim": "^0.1.0", "intl": "^1.2.4", "json-loader": "^0.5.4", + "ng-router-loader": "^1.0.2", "ng2-bootstrap": "1.1.16-10", "ng2-file-upload": "^1.1.4-2", "ng2-meta": "https://github.com/chocobozzz/ng2-meta#build", - "ng-router-loader": "^1.0.2", "ngc-webpack": "1.1.0", "node-sass": "^4.1.1", "normalize.css": "^5.0.0", + "optimize-js-plugin": "0.0.4", "raw-loader": "^0.5.1", "reflect-metadata": "^0.1.9", "resolve-url-loader": "^1.6.0", @@ -74,7 +75,6 @@ "tslint-loader": "^3.3.0", "typescript": "~2.1.0", "url-loader": "^0.5.7", - "v8-lazy-parse-webpack-plugin": "^0.3.0", "video.js": "^5.11.9", "videojs-dock": "^2.0.2", "webpack": "2.2.0-rc.3",