X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fconfig%2Fwebpack.production.config.js;h=f78ff4261cfde803ba1018305b9c0e832dfbafa7;hp=49ad6317ade8f55b773a4a47959de3688409ca8b;hb=f2dc2462571800e62cba969964de621dca09299c;hpb=dfe972ff7c9f7b6b1d730e66b0b2aa8df2ce329b diff --git a/skyquake/plugins/config/webpack.production.config.js b/skyquake/plugins/config/webpack.production.config.js index 49ad6317a..f78ff4261 100644 --- a/skyquake/plugins/config/webpack.production.config.js +++ b/skyquake/plugins/config/webpack.production.config.js @@ -1,7 +1,7 @@ /* * STANDARD_RIFT_IO_COPYRIGHT */ -var Webpack = require('webpack'); +var webpack = require('webpack'); var path = require('path'); var nodeModulesPath = path.resolve(__dirname, 'node_modules'); var buildPath = path.resolve(__dirname, 'public', 'build'); @@ -9,7 +9,7 @@ var mainPath = path.resolve(__dirname, 'src', 'main.js'); var uiPluginCmakeBuild = process.env.ui_plugin_cmake_build || false; var frameworkPath = uiPluginCmakeBuild?'../../../../skyquake/skyquake-build/framework':'../../framework'; var HtmlWebpackPlugin = require('html-webpack-plugin'); -var CommonsPlugin = new require("webpack/lib/optimize/CommonsChunkPlugin") +var CompressionPlugin = require("compression-webpack-plugin"); // Added to overcome node-sass bug https://github.com/iam4x/isomorphic-flux-boilerplate/issues/62 process.env.UV_THREADPOOL_SIZE=64; var config = { @@ -52,10 +52,24 @@ var config = { }, plugins: [ new HtmlWebpackPlugin({ - filename: '../index.html' - , templateContent: '
' - }), - new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity) + filename: '../index.html', + templateContent: '
' + }) ] }; + +if (process.argv.indexOf('--optimize-minimize') !== -1) { + // we are going to output a gzip file in the production process + config.output.filename = "gzip-" + config.output.filename; + config.plugins.push(new webpack.DefinePlugin({ // <-- key to reducing React's size + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + })); + config.plugins.push(new CompressionPlugin({ + asset: "[path]", // overwrite js file with gz file + algorithm: "gzip", + test: /\.(js)$/ + })); +} module.exports = config;