From efcca9816240e4cd87e524776885551ed534aa9d Mon Sep 17 00:00:00 2001 From: Bob Gallagher Date: Wed, 15 Mar 2017 08:24:47 -0400 Subject: [PATCH] =?utf8?q?Rift-15726=20compress=20code=20in=20production?= =?utf8?q?=20environment=20When=20webpack=20configs=20for=20=E2=80=9Cminim?= =?utf8?q?izing=E2=80=9D=20=20-=20define=20NODE=5FENV=20to=20be=20?= =?utf8?q?=E2=80=98production=E2=80=99=20to=20get=20further=20code=20reduc?= =?utf8?q?tion=20our=20of=20react=20=20-=20add=20in=20gzip=20compression?= =?utf8?q?=20Update=20skyquake.js=20to=20handle=20qzip=20file=20request=20?= =?utf8?q?Update=20all=20calls=20to=20alt.createStore=20to=20pass=20in=20a?= =?utf8?q?n=20explicit=20store=20name=20to=20fix=20issue=20caused=20by=20m?= =?utf8?q?inification=20(class=20name=20duplication?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I2bb2239c87c6b2f5f6f02399f553e28ee3a8f5b8 Signed-off-by: Bob Gallagher --- .../framework/widgets/header/headerStore.js | 2 +- .../skyquakeContainerStore.js | 2 +- skyquake/plugins/about/package.json | 1 + skyquake/plugins/about/src/aboutStore.js | 2 +- .../about/webpack.production.config.js | 26 +++++++++--- skyquake/plugins/accounts/package.json | 1 + .../accounts/webpack.production.config.js | 26 +++++++++--- skyquake/plugins/composer/package.json | 1 + .../composer/webpack.production.config.js | 42 ++++++++++++------- skyquake/plugins/config/package.json | 1 + .../config/webpack.production.config.js | 26 +++++++++--- skyquake/plugins/debug/package.json | 1 + skyquake/plugins/debug/src/crashStore.js | 2 +- .../debug/webpack.production.config.js | 25 ++++++++--- skyquake/plugins/goodbyeworld/package.json | 1 + .../goodbyeworld/webpack.production.config.js | 23 ++++++++-- skyquake/plugins/helloworld/package.json | 1 + .../helloworld/webpack.production.config.js | 25 ++++++++--- skyquake/plugins/launchpad/package.json | 3 +- skyquake/plugins/launchpad/src/createStore.js | 2 +- .../src/instantiate/instantiateDashboard.jsx | 2 +- .../src/instantiate/instantiateStore.js | 1 - .../launchpad/src/launchpadFleetStore.js | 2 +- .../src/recordViewer/recordViewStore.js | 2 +- .../launchpad/src/ssh_keys/sshKeys.jsx | 2 +- .../src/topologyL2View/topologyL2Store.js | 2 +- .../src/topologyView/topologyStore.js | 2 +- .../src/virtual_links/nsVirtualLinkCreate.jsx | 3 +- .../src/virtual_links/nsVirtualLinks.jsx | 3 +- .../plugins/launchpad/src/vnfr/vnfrStore.js | 2 +- .../launchpad/webpack.production.config.js | 27 +++++++++--- skyquake/plugins/logging/package.json | 1 + skyquake/plugins/logging/src/loggingStore.js | 2 +- .../logging/webpack.production.config.js | 25 ++++++++--- skyquake/skyquake.js | 7 ++++ skyquake/tests/stories/catalogCard.js | 2 +- skyquake/tests/stories/sshKeyCard.js | 2 +- 37 files changed, 224 insertions(+), 76 deletions(-) diff --git a/skyquake/framework/widgets/header/headerStore.js b/skyquake/framework/widgets/header/headerStore.js index 4ee86ffd6..150b32589 100644 --- a/skyquake/framework/widgets/header/headerStore.js +++ b/skyquake/framework/widgets/header/headerStore.js @@ -43,4 +43,4 @@ class HeaderStoreConstructor { } } -export default Alt.createStore(HeaderStoreConstructor) +export default Alt.createStore(HeaderStoreConstructor, 'HeaderStoreConstructor') diff --git a/skyquake/framework/widgets/skyquake_container/skyquakeContainerStore.js b/skyquake/framework/widgets/skyquake_container/skyquakeContainerStore.js index d1a8a9e28..f69014ebf 100644 --- a/skyquake/framework/widgets/skyquake_container/skyquakeContainerStore.js +++ b/skyquake/framework/widgets/skyquake_container/skyquakeContainerStore.js @@ -236,4 +236,4 @@ function getCurrentPlugin() { } } -export default Alt.createStore(SkyquakeContainerStore); +export default Alt.createStore(SkyquakeContainerStore, 'SkyquakeContainerStore'); diff --git a/skyquake/plugins/about/package.json b/skyquake/plugins/about/package.json index cb92cf9b0..46829d538 100644 --- a/skyquake/plugins/about/package.json +++ b/skyquake/plugins/about/package.json @@ -37,6 +37,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", diff --git a/skyquake/plugins/about/src/aboutStore.js b/skyquake/plugins/about/src/aboutStore.js index 934522bb3..bc94127b0 100644 --- a/skyquake/plugins/about/src/aboutStore.js +++ b/skyquake/plugins/about/src/aboutStore.js @@ -37,5 +37,5 @@ aboutStore.prototype.getCreateTimeSuccess = function(time) { console.log('uptime success', time) } -module.exports = Alt.createStore(aboutStore);; +module.exports = Alt.createStore(aboutStore, 'aboutStore');; diff --git a/skyquake/plugins/about/webpack.production.config.js b/skyquake/plugins/about/webpack.production.config.js index 5be840c4c..4a2aa12d9 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,6 +23,8 @@ 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 config = { @@ -65,10 +67,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; diff --git a/skyquake/plugins/accounts/package.json b/skyquake/plugins/accounts/package.json index e12604270..d6050800a 100644 --- a/skyquake/plugins/accounts/package.json +++ b/skyquake/plugins/accounts/package.json @@ -38,6 +38,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", diff --git a/skyquake/plugins/accounts/webpack.production.config.js b/skyquake/plugins/accounts/webpack.production.config.js index 3984a5857..6356ddbac 100644 --- a/skyquake/plugins/accounts/webpack.production.config.js +++ b/skyquake/plugins/accounts/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,7 +23,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 = { @@ -66,10 +66,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; diff --git a/skyquake/plugins/composer/package.json b/skyquake/plugins/composer/package.json index 6a01af1e4..5b4523935 100644 --- a/skyquake/plugins/composer/package.json +++ b/skyquake/plugins/composer/package.json @@ -53,6 +53,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "css-loader": "^0.23.0", "eslint": "^1.10.2", "eslint-loader": "^1.1.1", diff --git a/skyquake/plugins/composer/webpack.production.config.js b/skyquake/plugins/composer/webpack.production.config.js index bf2747a74..7839f1029 100644 --- a/skyquake/plugins/composer/webpack.production.config.js +++ b/skyquake/plugins/composer/webpack.production.config.js @@ -28,14 +28,15 @@ var path = require('path'); 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; -module.exports = { +var config = { devtool: 'source-map', output: { publicPath: 'assets/', path: 'public/assets/', - filename: 'src/main.js' + filename: 'bundle.js' }, debug: false, @@ -60,18 +61,6 @@ module.exports = { 'helpers': path.join(process.cwd(), './test/helpers/') } }, - plugins: [ - // new webpack.optimize.DedupePlugin(), - // new webpack.optimize.UglifyJsPlugin(), - // new webpack.optimize.OccurenceOrderPlugin(), - // new webpack.optimize.AggressiveMergingPlugin(), - // new webpack.NoErrorsPlugin(), - new HtmlWebpackPlugin({ - filename: '../index.html' - , templateContent: '
' - }) - ], - module: { noParse: [/autoit.js/], // preLoaders: [ @@ -101,5 +90,28 @@ module.exports = { }, { test: /\.json$/, loader: "json-loader" }, ] - } + }, + plugins: [ + new HtmlWebpackPlugin({ + 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; \ No newline at end of file diff --git a/skyquake/plugins/config/package.json b/skyquake/plugins/config/package.json index b4de560f1..ff3212a3d 100644 --- a/skyquake/plugins/config/package.json +++ b/skyquake/plugins/config/package.json @@ -38,6 +38,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", 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; diff --git a/skyquake/plugins/debug/package.json b/skyquake/plugins/debug/package.json index fd2dea95f..2395b1468 100644 --- a/skyquake/plugins/debug/package.json +++ b/skyquake/plugins/debug/package.json @@ -35,6 +35,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", diff --git a/skyquake/plugins/debug/src/crashStore.js b/skyquake/plugins/debug/src/crashStore.js index c5ded180e..51857d51f 100644 --- a/skyquake/plugins/debug/src/crashStore.js +++ b/skyquake/plugins/debug/src/crashStore.js @@ -35,5 +35,5 @@ crashStore.prototype.getCrashDetailsFailure = function(info) { console.log('Failed to retrieve crash/debug details', info) }; -module.exports = Alt.createStore(crashStore);; +module.exports = Alt.createStore(crashStore, 'crashStore');; diff --git a/skyquake/plugins/debug/webpack.production.config.js b/skyquake/plugins/debug/webpack.production.config.js index 5be840c4c..2ef01beea 100644 --- a/skyquake/plugins/debug/webpack.production.config.js +++ b/skyquake/plugins/debug/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,6 +23,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 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 = { @@ -65,10 +66,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; diff --git a/skyquake/plugins/goodbyeworld/package.json b/skyquake/plugins/goodbyeworld/package.json index ebb138c54..a6d1bba4e 100644 --- a/skyquake/plugins/goodbyeworld/package.json +++ b/skyquake/plugins/goodbyeworld/package.json @@ -15,6 +15,7 @@ "babel-preset-es2015": "^6.3.13", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "express": "^4.13.3", "history": "^1.17.0", "json-loader": "^0.5.4", diff --git a/skyquake/plugins/goodbyeworld/webpack.production.config.js b/skyquake/plugins/goodbyeworld/webpack.production.config.js index e013478ad..7db6acc65 100644 --- a/skyquake/plugins/goodbyeworld/webpack.production.config.js +++ b/skyquake/plugins/goodbyeworld/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,6 +23,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 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 = { @@ -64,10 +65,24 @@ var config = { }, plugins: [ new HtmlWebpackPlugin({ - filename: '../index.html', + filename: '../index.html', templateContent: '
' - }), - new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity) + }) ] }; + +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; diff --git a/skyquake/plugins/helloworld/package.json b/skyquake/plugins/helloworld/package.json index c874218ad..df748a3de 100644 --- a/skyquake/plugins/helloworld/package.json +++ b/skyquake/plugins/helloworld/package.json @@ -15,6 +15,7 @@ "babel-preset-es2015": "^6.3.13", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "express": "^4.13.3", "history": "^1.17.0", "json-loader": "^0.5.4", diff --git a/skyquake/plugins/helloworld/webpack.production.config.js b/skyquake/plugins/helloworld/webpack.production.config.js index e5728d017..7db6acc65 100644 --- a/skyquake/plugins/helloworld/webpack.production.config.js +++ b/skyquake/plugins/helloworld/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,6 +23,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 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 = { @@ -64,10 +65,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; diff --git a/skyquake/plugins/launchpad/package.json b/skyquake/plugins/launchpad/package.json index 7c531b440..f6471abd0 100644 --- a/skyquake/plugins/launchpad/package.json +++ b/skyquake/plugins/launchpad/package.json @@ -40,6 +40,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", @@ -50,7 +51,7 @@ "react-addons-css-transition-group": "^0.14.7", "sass-loader": "^3.1.2", "style-loader": "^0.13.0", - "webpack": "^1.3.0", + "webpack": "~1.14.0", "webpack-dev-server": "^1.10.1" } } diff --git a/skyquake/plugins/launchpad/src/createStore.js b/skyquake/plugins/launchpad/src/createStore.js index 517c70c3b..da79e8a7e 100644 --- a/skyquake/plugins/launchpad/src/createStore.js +++ b/skyquake/plugins/launchpad/src/createStore.js @@ -54,5 +54,5 @@ CreateFleet.prototype.validateReset = function() { }); }; -module.exports = alt.createStore(CreateFleet); +module.exports = alt.createStore(CreateFleet, 'CreateFleet'); diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx b/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx index 9c358e8c0..7bed778e9 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx @@ -31,7 +31,7 @@ import './instantiateDashboard.scss'; class InstantiateDashboard extends React.Component { constructor(props) { super(props); - this.Store = this.props.flux.stores.hasOwnProperty('InstantiateStore') ? this.props.flux.stores.InstantiateStore : this.props.flux.createStore(InstantiateStore ); + this.Store = this.props.flux.stores.hasOwnProperty('InstantiateStore') ? this.props.flux.stores.InstantiateStore : this.props.flux.createStore(InstantiateStore, 'InstantiateStore'); this.state = this.Store.getState(); } componentDidMount() { diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js index e779beb16..01c624d57 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateStore.js @@ -851,5 +851,4 @@ function getMockData() { pnfd: data.pnfd }); } -// export default Alt.createStore(LaunchNetworkServiceStore); export default LaunchNetworkServiceStore; diff --git a/skyquake/plugins/launchpad/src/launchpadFleetStore.js b/skyquake/plugins/launchpad/src/launchpadFleetStore.js index 520eebecd..a4b622b3c 100644 --- a/skyquake/plugins/launchpad/src/launchpadFleetStore.js +++ b/skyquake/plugins/launchpad/src/launchpadFleetStore.js @@ -279,5 +279,5 @@ FleetStoreConstructor.prototype.getVDUConsoleLinkSuccess = function(data) { data['console-url'] && window.open(data['console-url']); } -FleetStore = Alt.createStore(FleetStoreConstructor); +FleetStore = Alt.createStore(FleetStoreConstructor, 'FleetStore'); module.exports = FleetStore; diff --git a/skyquake/plugins/launchpad/src/recordViewer/recordViewStore.js b/skyquake/plugins/launchpad/src/recordViewer/recordViewStore.js index a7770a7fa..4a5b49cca 100644 --- a/skyquake/plugins/launchpad/src/recordViewer/recordViewStore.js +++ b/skyquake/plugins/launchpad/src/recordViewer/recordViewStore.js @@ -472,4 +472,4 @@ function connectionManager(type, connection) { }; } -export default Alt.createStore(RecordViewStore); +export default Alt.createStore(RecordViewStore, 'RecordViewStore'); diff --git a/skyquake/plugins/launchpad/src/ssh_keys/sshKeys.jsx b/skyquake/plugins/launchpad/src/ssh_keys/sshKeys.jsx index f832215ad..3d4179eed 100644 --- a/skyquake/plugins/launchpad/src/ssh_keys/sshKeys.jsx +++ b/skyquake/plugins/launchpad/src/ssh_keys/sshKeys.jsx @@ -27,7 +27,7 @@ import '../../node_modules/open-iconic/font/css/open-iconic.css'; class SshKeys extends Component { constructor(props) { super(props); - this.Store = this.props.flux.stores.hasOwnProperty('SshKeyStore') ? this.props.flux.stores.SshKeyStore : this.props.flux.createStore(SshKeyStore); + this.Store = this.props.flux.stores.hasOwnProperty('SshKeyStore') ? this.props.flux.stores.SshKeyStore : this.props.flux.createStore(SshKeyStore, 'SshKeyStore'); this.state = this.Store.getState(); this.Store.listen(this.handleUpdate); } diff --git a/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Store.js b/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Store.js index 2d1495209..b6bed73f3 100644 --- a/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Store.js +++ b/skyquake/plugins/launchpad/src/topologyL2View/topologyL2Store.js @@ -132,4 +132,4 @@ class TopologyL2Store { }); } } - export default Alt.createStore(TopologyL2Store); + export default Alt.createStore(TopologyL2Store, 'TopologyL2Store'); diff --git a/skyquake/plugins/launchpad/src/topologyView/topologyStore.js b/skyquake/plugins/launchpad/src/topologyView/topologyStore.js index 10c5005d2..5d6cef98b 100644 --- a/skyquake/plugins/launchpad/src/topologyView/topologyStore.js +++ b/skyquake/plugins/launchpad/src/topologyView/topologyStore.js @@ -135,4 +135,4 @@ class TopologyStore { } } -export default Alt.createStore(TopologyStore); +export default Alt.createStore(TopologyStore, 'TopologyStore'); diff --git a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinkCreate.jsx b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinkCreate.jsx index d3dc011f1..dcd0f5bca 100644 --- a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinkCreate.jsx +++ b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinkCreate.jsx @@ -31,7 +31,8 @@ import SelectOption from 'widgets/form_controls/selectOption.jsx'; class NsVirtualLinkCreate extends React.Component { constructor(props) { super(props); - this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore); + this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? + this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore, 'NSVirtualLinkCreateStore'); this.state = this.Store.getState(); this.Store.listen(this.handleUpdate); } diff --git a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx index fa09d9ffa..2f5b15b24 100644 --- a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx +++ b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx @@ -29,7 +29,8 @@ import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx' class NsVirtualLinks extends React.Component { constructor(props) { super(props); - this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore); + this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? + this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore, 'NSVirtualLinkCreateStore'); this.state = {}; this.state.mode = 'viewing'; // Can be 'viewing'/'creating'/'editing'/'deleting'. Default is 'viewing' this.selectedVirtualLink = null; diff --git a/skyquake/plugins/launchpad/src/vnfr/vnfrStore.js b/skyquake/plugins/launchpad/src/vnfr/vnfrStore.js index 9a64531d6..5e09d7a6a 100644 --- a/skyquake/plugins/launchpad/src/vnfr/vnfrStore.js +++ b/skyquake/plugins/launchpad/src/vnfr/vnfrStore.js @@ -63,4 +63,4 @@ class VnfrStore { } }; -export default alt.createStore(VnfrStore) +export default alt.createStore(VnfrStore, 'VnfrStore') diff --git a/skyquake/plugins/launchpad/webpack.production.config.js b/skyquake/plugins/launchpad/webpack.production.config.js index 3984a5857..ed2a23f6d 100644 --- a/skyquake/plugins/launchpad/webpack.production.config.js +++ b/skyquake/plugins/launchpad/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,7 +23,8 @@ 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 = { @@ -66,10 +67,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; diff --git a/skyquake/plugins/logging/package.json b/skyquake/plugins/logging/package.json index ae4ef97e3..d58e262cb 100644 --- a/skyquake/plugins/logging/package.json +++ b/skyquake/plugins/logging/package.json @@ -37,6 +37,7 @@ "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.3.13", "babel-runtime": "^6.3.19", + "compression-webpack-plugin": "^0.3.2", "cors": "^2.7.1", "css-loader": "^0.23.1", "file-loader": "^0.8.5", diff --git a/skyquake/plugins/logging/src/loggingStore.js b/skyquake/plugins/logging/src/loggingStore.js index 6743b92c5..e95e657cd 100644 --- a/skyquake/plugins/logging/src/loggingStore.js +++ b/skyquake/plugins/logging/src/loggingStore.js @@ -216,4 +216,4 @@ class LoggingStore { } } -export default alt.createStore(LoggingStore); +export default alt.createStore(LoggingStore, 'LoggingStore'); diff --git a/skyquake/plugins/logging/webpack.production.config.js b/skyquake/plugins/logging/webpack.production.config.js index 87e91c766..a4e48347d 100644 --- a/skyquake/plugins/logging/webpack.production.config.js +++ b/skyquake/plugins/logging/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,6 +23,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 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 = { @@ -65,10 +66,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; diff --git a/skyquake/skyquake.js b/skyquake/skyquake.js index 726757fbb..9b52e96eb 100644 --- a/skyquake/skyquake.js +++ b/skyquake/skyquake.js @@ -248,6 +248,13 @@ if (cluster.isMaster && clusteredLaunch) { app.get('/multiplex-client', function(req, res) { res.sendFile(__dirname + '/node_modules/websocket-multiplex/multiplex_client.js'); }); + + // handle requests for gzip'd files + app.get('*gzip*', function (req, res, next) { + res.set('Content-Encoding', 'gzip'); + next(); + }); + } /** diff --git a/skyquake/tests/stories/catalogCard.js b/skyquake/tests/stories/catalogCard.js index b7e0e5769..143dfe83e 100644 --- a/skyquake/tests/stories/catalogCard.js +++ b/skyquake/tests/stories/catalogCard.js @@ -11,7 +11,7 @@ import Alt from '../../framework/widgets/skyquake_container/skyquakeAltInstance. import {Panel, PanelWrapper} from '../../framework/widgets/panel/panel.jsx' import '../../node_modules/open-iconic/font/css/open-iconic.css'; import 'style/base.scss'; -const Store = Alt.createStore(InstantiateStore) +const Store = Alt.createStore(InstantiateStore, 'InstantiateStore'); // import StyleGuideItem from 'react-style-guide'; // import '../../node_modules/react-style-guide/node_modules/highlight.js/styles/github.css'; let SampleNSD = { diff --git a/skyquake/tests/stories/sshKeyCard.js b/skyquake/tests/stories/sshKeyCard.js index 649ec4ad1..dcaf41775 100644 --- a/skyquake/tests/stories/sshKeyCard.js +++ b/skyquake/tests/stories/sshKeyCard.js @@ -11,7 +11,7 @@ import 'style/base.scss'; // import StyleGuideItem from 'react-style-guide'; // import '../../node_modules/react-style-guide/node_modules/highlight.js/styles/github.css'; -const Store = Alt.createStore(SshKeyStore) +const Store = Alt.createStore(SshKeyStore, 'SshKeyStore'); storiesOf('CatalogCard', module) // .add('page', () => ()) -- 2.25.1