From 85939d12485513b06e89245ded9af6a2745b75aa Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Thu, 28 Apr 2016 20:00:42 +0200 Subject: [PATCH] Add /dev.html page w/ full redux dev tools * normal page wont have store instrumented to stay lean * reshuffled vendor deps to balance bundle sizes --- client/app/scripts/main.dev.js | 2 +- client/app/scripts/main.js | 27 +++++++++++++++---- client/app/scripts/main.prod.js | 22 --------------- client/app/scripts/stores/configureStore.js | 15 ++++++++--- .../app/scripts/stores/configureStore.prod.js | 12 --------- client/webpack.local.config.js | 17 +++++++++--- client/webpack.production.config.js | 5 ++-- 7 files changed, 51 insertions(+), 49 deletions(-) delete mode 100644 client/app/scripts/main.prod.js delete mode 100644 client/app/scripts/stores/configureStore.prod.js diff --git a/client/app/scripts/main.dev.js b/client/app/scripts/main.dev.js index 1aa991bb1..377885d63 100644 --- a/client/app/scripts/main.dev.js +++ b/client/app/scripts/main.dev.js @@ -7,7 +7,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; -import configureStore from './stores/configureStore'; +import configureStore from './stores/configureStore.dev'; import App from './components/app'; import DevTools from './components/dev-tools'; diff --git a/client/app/scripts/main.js b/client/app/scripts/main.js index 5c3028e81..0132b87bb 100644 --- a/client/app/scripts/main.js +++ b/client/app/scripts/main.js @@ -1,5 +1,22 @@ -if (process.env.NODE_ENV === 'production') { - module.exports = require('./main.prod'); -} else { - module.exports = require('./main.dev'); -} +require('font-awesome-webpack'); +require('../styles/main.less'); +require('../images/favicon.ico'); + +import 'babel-polyfill'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import { Provider } from 'react-redux'; + +import configureStore from './stores/configureStore'; +import App from './components/app'; + +const store = configureStore(); + +ReactDOM.render( + +
+ +
+
, + document.getElementById('app') +); diff --git a/client/app/scripts/main.prod.js b/client/app/scripts/main.prod.js deleted file mode 100644 index 0132b87bb..000000000 --- a/client/app/scripts/main.prod.js +++ /dev/null @@ -1,22 +0,0 @@ -require('font-awesome-webpack'); -require('../styles/main.less'); -require('../images/favicon.ico'); - -import 'babel-polyfill'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Provider } from 'react-redux'; - -import configureStore from './stores/configureStore'; -import App from './components/app'; - -const store = configureStore(); - -ReactDOM.render( - -
- -
-
, - document.getElementById('app') -); diff --git a/client/app/scripts/stores/configureStore.js b/client/app/scripts/stores/configureStore.js index 78c9ea1fd..f61d8a847 100644 --- a/client/app/scripts/stores/configureStore.js +++ b/client/app/scripts/stores/configureStore.js @@ -1,5 +1,12 @@ -if (process.env.NODE_ENV === 'production') { - module.exports = require('./configureStore.prod'); -} else { - module.exports = require('./configureStore.dev'); +import { createStore, applyMiddleware } from 'redux'; +import thunkMiddleware from 'redux-thunk'; + +import { initialState, rootReducer } from '../reducers/root'; + +export default function configureStore() { + return createStore( + rootReducer, + initialState, + applyMiddleware(thunkMiddleware) + ); } diff --git a/client/app/scripts/stores/configureStore.prod.js b/client/app/scripts/stores/configureStore.prod.js deleted file mode 100644 index f61d8a847..000000000 --- a/client/app/scripts/stores/configureStore.prod.js +++ /dev/null @@ -1,12 +0,0 @@ -import { createStore, applyMiddleware } from 'redux'; -import thunkMiddleware from 'redux-thunk'; - -import { initialState, rootReducer } from '../reducers/root'; - -export default function configureStore() { - return createStore( - rootReducer, - initialState, - applyMiddleware(thunkMiddleware) - ); -} diff --git a/client/webpack.local.config.js b/client/webpack.local.config.js index d669320d7..95ae08f87 100644 --- a/client/webpack.local.config.js +++ b/client/webpack.local.config.js @@ -29,6 +29,11 @@ module.exports = { 'webpack-dev-server/client?http://' + WEBPACK_SERVER_HOST + ':4041', 'webpack/hot/only-dev-server' ], + 'dev-app': [ + './app/scripts/main.dev', + 'webpack-dev-server/client?http://' + WEBPACK_SERVER_HOST + ':4041', + 'webpack/hot/only-dev-server' + ], 'contrast-app': [ './app/scripts/contrast-main', 'webpack-dev-server/client?http://' + WEBPACK_SERVER_HOST + ':4041', @@ -39,9 +44,10 @@ module.exports = { 'webpack-dev-server/client?http://' + WEBPACK_SERVER_HOST + ':4041', 'webpack/hot/only-dev-server' ], - vendors: ['babel-polyfill', 'classnames', 'd3', 'dagre', 'immutable', - 'lodash', 'page', 'react', 'react-dom', 'react-redux', 'react-motion', - 'redux', 'redux-thunk'] + vendors: ['babel-polyfill', 'classnames', 'd3', 'dagre', 'filesize', + 'immutable', 'lodash', 'moment', 'page', 'react', + 'react-dom', 'react-motion', 'react-redux', 'redux', 'redux-thunk', + 'reqwest'] }, // This will not actually create a app.js file in ./build. It is used @@ -66,6 +72,11 @@ module.exports = { template: 'app/html/index.html', filename: 'terminal.html' }), + new HtmlWebpackPlugin({ + chunks: ['vendors', 'dev-app'], + template: 'app/html/index.html', + filename: 'dev.html' + }), new HtmlWebpackPlugin({ chunks: ['vendors', 'app'], template: 'app/html/index.html', diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js index 7d2d1c5ff..8b2fb4c14 100644 --- a/client/webpack.production.config.js +++ b/client/webpack.production.config.js @@ -24,8 +24,9 @@ module.exports = { app: './app/scripts/main', 'contrast-app': './app/scripts/contrast-main', 'terminal-app': './app/scripts/terminal-main', - vendors: ['babel-polyfill', 'classnames', 'd3', 'dagre', 'immutable', - 'lodash', 'page', 'react', 'react-dom', 'react-redux', 'react-motion', + // keep only some in here, to make vendors and app bundles roughly same size + vendors: ['babel-polyfill', 'classnames', 'd3', 'immutable', + 'lodash', 'react', 'react-dom', 'react-redux', 'redux', 'redux-thunk'] },