adding function to check node_env (#414)

This commit is contained in:
Alex Windett 2017-03-29 09:52:33 +01:00 committed by GitHub
parent 54216ae3d0
commit fe6d3e3228
7 changed files with 12 additions and 10 deletions

View File

@ -10,7 +10,8 @@ import Home from '@containers/home';
import NotFound from '@containers/not-found'; import NotFound from '@containers/not-found';
import Nav from '@components/navigation'; import Nav from '@components/navigation';
import OrgNavigation from '@components/navigation/org'; import OrgNavigation from '@components/navigation/org';
import PerfProfiler from '../perf-profiler'; import { isProduction } from '@utils';
import PerfProfiler from '@perf-profiler';
import React from 'react'; import React from 'react';
const App = connect()(React.createClass({ const App = connect()(React.createClass({
@ -33,7 +34,7 @@ const App = connect()(React.createClass({
return _children; return _children;
} }
if (process.env.NODE_ENV !== 'production' && process.env.BASELINE_GRID) { if ( !isProduction() && process.env.BASELINE_GRID) {
_children = ( _children = (
<BaselineGrid> <BaselineGrid>
{_children} {_children}
@ -51,7 +52,7 @@ const App = connect()(React.createClass({
export default (props) => ( export default (props) => (
<div> <div>
{ process.env.NODE_ENV !== 'production' && <PerfProfiler /> } { !isProduction() && <PerfProfiler /> }
<App {...props}> <App {...props}>
<Header /> <Header />

View File

@ -13,8 +13,9 @@ import MockState from '@mock-states';
import LeakDatasets from './dataset-leak.json'; import LeakDatasets from './dataset-leak.json';
import NormalDatasets from './dataset-normal.json'; import NormalDatasets from './dataset-normal.json';
import Store from '@state/store'; import Store from '@state/store';
import { isProduction } from '@utils';
if (process.env.NODE_ENV !== 'production') { if ( !isProduction() ) {
a11y(React, { a11y(React, {
ReactDOM ReactDOM
}); });

View File

@ -12,6 +12,7 @@ const Profiler = styled.div`
background: #bada55; background: #bada55;
border: 2px solid black; border: 2px solid black;
text-align: center; text-align: center;
z-index: 1;
& > h1 { & > h1 {
font-size: 1.5em; font-size: 1.5em;

View File

@ -6,6 +6,7 @@ import thunk from 'redux-thunk';
import perflogger from 'redux-perf-middleware'; import perflogger from 'redux-perf-middleware';
import createReducer from '@state/reducers'; import createReducer from '@state/reducers';
import { isProduction } from '@utils';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
@ -18,7 +19,7 @@ export default (state = Object.freeze({})) => {
createLogger(), createLogger(),
promiseMiddleware(), promiseMiddleware(),
thunk, thunk,
process.env.NODE_ENV !== 'production' && perflogger !isProduction() && perflogger
) )
) )
); );

View File

@ -0,0 +1 @@
export const isProduction = () => process.env.NODE_ENV === 'production';

View File

@ -9,8 +9,7 @@ const {
MODULES, MODULES,
FRONTEND, FRONTEND,
UI, UI,
STATIC, STATIC
MOCKSTATE
} = paths; } = paths;
module.exports = { module.exports = {
@ -25,8 +24,7 @@ module.exports = {
[`@${path.basename(fullpath)}`]: fullpath [`@${path.basename(fullpath)}`]: fullpath
}), { }), {
'@root': FRONTEND, '@root': FRONTEND,
'@ui': UI, '@ui': UI
'@mock-states': MOCKSTATE
}) })
}, },
resolveLoader: { resolveLoader: {

View File

@ -14,7 +14,6 @@ module.exports = {
'node_modules' 'node_modules'
], ],
FRONTEND: path.join(FRONTEND, 'src'), FRONTEND: path.join(FRONTEND, 'src'),
MOCKSTATE: path.join(FRONTEND, 'src/mock-states'),
UI: process.env.NODE_ENV === 'production' UI: process.env.NODE_ENV === 'production'
? path.join(FRONTEND, 'node_modules', '@tomgco/joyent-portal-ui', 'dist') ? path.join(FRONTEND, 'node_modules', '@tomgco/joyent-portal-ui', 'dist')
: path.join(UI, 'src'), : path.join(UI, 'src'),