X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fabout%2Fwebpack.production.config.js;h=a2fa842ded32b5e82a7e4ee24e1a5d1e1eb90dcb;hp=5be840c4c3c3d6d96cb12a069f02cf7723e4ff14;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=e29efc315df33d546237e270470916e26df391d6 diff --git a/skyquake/plugins/about/webpack.production.config.js b/skyquake/plugins/about/webpack.production.config.js index 5be840c4c..a2fa842de 100644 --- a/skyquake/plugins/about/webpack.production.config.js +++ b/skyquake/plugins/about/webpack.production.config.js @@ -15,7 +15,7 @@ * limitations under the License. * */ -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'); @@ -23,8 +23,11 @@ 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 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 htmlFilename = (process.argv.indexOf('--production-debug') !== -1) ? 'debug.html' : 'index.html'; var config = { devtool: 'source-map', entry: mainPath, @@ -65,10 +68,24 @@ var config = { }, plugins: [ new HtmlWebpackPlugin({ - filename: '../index.html' - , templateContent: '
' - }), - new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity) + filename: '../' + htmlFilename, + template: frameworkPath + '/plugin-index.html' + }) ] }; + +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;