Rift-15726 compress code in production environment 98/1298/1
authorBob Gallagher <bob.gallagher@riftio.com>
Wed, 15 Mar 2017 12:24:47 +0000 (08:24 -0400)
committerBob Gallagher <bob.gallagher@riftio.com>
Wed, 15 Mar 2017 12:24:47 +0000 (08:24 -0400)
When webpack configs for “minimizing”
 - define NODE_ENV to be ‘production’ to get further code reduction our of react
 - add in gzip compression
Update skyquake.js to handle qzip file request
Update all calls to alt.createStore to pass in an explicit store name to fix issue caused by minification (class name duplication

Change-Id: I2bb2239c87c6b2f5f6f02399f553e28ee3a8f5b8
Signed-off-by: Bob Gallagher <bob.gallagher@riftio.com>
37 files changed:
skyquake/framework/widgets/header/headerStore.js
skyquake/framework/widgets/skyquake_container/skyquakeContainerStore.js
skyquake/plugins/about/package.json
skyquake/plugins/about/src/aboutStore.js
skyquake/plugins/about/webpack.production.config.js
skyquake/plugins/accounts/package.json
skyquake/plugins/accounts/webpack.production.config.js
skyquake/plugins/composer/package.json
skyquake/plugins/composer/webpack.production.config.js
skyquake/plugins/config/package.json
skyquake/plugins/config/webpack.production.config.js
skyquake/plugins/debug/package.json
skyquake/plugins/debug/src/crashStore.js
skyquake/plugins/debug/webpack.production.config.js
skyquake/plugins/goodbyeworld/package.json
skyquake/plugins/goodbyeworld/webpack.production.config.js
skyquake/plugins/helloworld/package.json
skyquake/plugins/helloworld/webpack.production.config.js
skyquake/plugins/launchpad/package.json
skyquake/plugins/launchpad/src/createStore.js
skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx
skyquake/plugins/launchpad/src/instantiate/instantiateStore.js
skyquake/plugins/launchpad/src/launchpadFleetStore.js
skyquake/plugins/launchpad/src/recordViewer/recordViewStore.js
skyquake/plugins/launchpad/src/ssh_keys/sshKeys.jsx
skyquake/plugins/launchpad/src/topologyL2View/topologyL2Store.js
skyquake/plugins/launchpad/src/topologyView/topologyStore.js
skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinkCreate.jsx
skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx
skyquake/plugins/launchpad/src/vnfr/vnfrStore.js
skyquake/plugins/launchpad/webpack.production.config.js
skyquake/plugins/logging/package.json
skyquake/plugins/logging/src/loggingStore.js
skyquake/plugins/logging/webpack.production.config.js
skyquake/skyquake.js
skyquake/tests/stories/catalogCard.js
skyquake/tests/stories/sshKeyCard.js

index 4ee86ff..150b325 100644 (file)
@@ -43,4 +43,4 @@ class HeaderStoreConstructor {
     }
 }
 
-export default Alt.createStore(HeaderStoreConstructor)
+export default Alt.createStore(HeaderStoreConstructor, 'HeaderStoreConstructor')
index d1a8a9e..f69014e 100644 (file)
@@ -236,4 +236,4 @@ function getCurrentPlugin() {
     }
 }
 
-export default Alt.createStore(SkyquakeContainerStore);
+export default Alt.createStore(SkyquakeContainerStore, 'SkyquakeContainerStore');
index cb92cf9..46829d5 100644 (file)
@@ -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",
index 934522b..bc94127 100644 (file)
@@ -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');;
 
index 5be840c..4a2aa12 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index e126042..d605080 100644 (file)
@@ -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",
index 3984a58..6356ddb 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index 6a01af1..5b45239 100644 (file)
@@ -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",
index bf2747a..7839f10 100644 (file)
@@ -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: '<div id="app"></div>'
-        })
-       ],
-
        module: {
                noParse: [/autoit.js/],
                // preLoaders: [
@@ -101,5 +90,28 @@ module.exports = {
                        },
                        { test: /\.json$/, loader: "json-loader" },
                ]
-       }
+       },
+    plugins: [
+        new HtmlWebpackPlugin({
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
+    ]
 };
+
+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
index b4de560..ff3212a 100644 (file)
@@ -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",
index 49ad631..f78ff42 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index fd2dea9..2395b14 100644 (file)
@@ -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",
index c5ded18..51857d5 100644 (file)
@@ -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');;
 
index 5be840c..2ef01be 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index ebb138c..a6d1bba 100644 (file)
@@ -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",
index e013478..7db6acc 100644 (file)
@@ -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: '<div id="content"></div>'
-        }),
-        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;
index c874218..df748a3 100644 (file)
@@ -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",
index e5728d0..7db6acc 100644 (file)
@@ -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: '<div id="content"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="content"></div>'
+        })
     ]
 };
+
+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;
index 7c531b4..f6471ab 100644 (file)
@@ -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"
   }
 }
index 517c70c..da79e8a 100644 (file)
@@ -54,5 +54,5 @@ CreateFleet.prototype.validateReset = function() {
   });
 };
 
-module.exports = alt.createStore(CreateFleet);
+module.exports = alt.createStore(CreateFleet, 'CreateFleet');
 
index 9c358e8..7bed778 100644 (file)
@@ -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() {
index e779beb..01c624d 100644 (file)
@@ -851,5 +851,4 @@ function getMockData() {
         pnfd: data.pnfd
     });
 }
-// export default Alt.createStore(LaunchNetworkServiceStore);
 export default LaunchNetworkServiceStore;
index 520eebe..a4b622b 100644 (file)
@@ -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;
index a7770a7..4a5b49c 100644 (file)
@@ -472,4 +472,4 @@ function connectionManager(type, connection) {
     };
 }
 
-export default Alt.createStore(RecordViewStore);
+export default Alt.createStore(RecordViewStore, 'RecordViewStore');
index f832215..3d4179e 100644 (file)
@@ -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);
     }
index 2d14952..b6bed73 100644 (file)
@@ -132,4 +132,4 @@ class TopologyL2Store {
         });
     }
 }
-    export default Alt.createStore(TopologyL2Store);
+    export default Alt.createStore(TopologyL2Store, 'TopologyL2Store');
index 10c5005..5d6cef9 100644 (file)
@@ -135,4 +135,4 @@ class TopologyStore {
     }
 
 }
-export default Alt.createStore(TopologyStore);
+export default Alt.createStore(TopologyStore, 'TopologyStore');
index d3dc011..dcd0f5b 100644 (file)
@@ -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);
        }
index fa09d9f..2f5b15b 100644 (file)
@@ -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;
index 9a64531..5e09d7a 100644 (file)
@@ -63,4 +63,4 @@ class VnfrStore {
   }
 };
 
-export default alt.createStore(VnfrStore)
+export default alt.createStore(VnfrStore, 'VnfrStore')
index 3984a58..ed2a23f 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index ae4ef97..d58e262 100644 (file)
@@ -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",
index 6743b92..e95e657 100644 (file)
@@ -216,4 +216,4 @@ class LoggingStore {
   }
 }
 
-export default alt.createStore(LoggingStore);
+export default alt.createStore(LoggingStore, 'LoggingStore');
index 87e91c7..a4e4834 100644 (file)
@@ -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: '<div id="app"></div>'
-        }),
-        new Webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", Infinity)
+            filename: '../index.html', 
+            templateContent: '<div id="app"></div>'
+        })
     ]
 };
+
+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;
index 726757f..9b52e96 100644 (file)
@@ -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();
+           });
+
        }
 
        /**
index b7e0e57..143dfe8 100644 (file)
@@ -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 = {
index 649ec4a..dcaf417 100644 (file)
@@ -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', () => (<SshKeys />))