🐛 Du code de développement était chargé en production

pull/166/head
mama 2018-02-01 18:24:23 +01:00
parent 645c2f4517
commit 3399eab5eb
7 changed files with 82 additions and 80 deletions

View File

@ -1,19 +1,13 @@
import React, { Component } from 'react'
import { Provider } from 'react-redux'
import React from 'react'
import DevTools from '../DevTools'
import { Provider } from 'react-redux'
import Layout from './Layout'
export default class App extends Component {
render() {
const { store } = this.props
return (
<Provider store={store}>
<div>
<Layout />
<DevTools />
</div>
</Provider>
)
}
}
export default ({ store }) => (
<Provider store={store}>
<div id="dev">
<Layout />
<DevTools />
</div>
</Provider>
)

View File

@ -1,3 +0,0 @@
if (process.env.NODE_ENV === 'production')
module.exports = require('./App.prod')
else module.exports = require('./App.dev')

View File

@ -1,18 +0,0 @@
// App.dev without the redux DevTools
import React, { Component } from 'react'
import { Provider } from 'react-redux'
import Layout from './Layout'
export default class App extends Component {
render() {
const { store } = this.props
return (
<Provider store={store}>
<div>
<Layout />
</div>
</Provider>
)
}
}

View File

@ -10,7 +10,7 @@ body {
background: white;
}
#js,
#js > div {
#dev {
height: 100%;
}

40
source/entry.dev.js Normal file
View File

@ -0,0 +1,40 @@
import React from 'react'
import { render } from 'react-dom'
import { compose, createStore, applyMiddleware } from 'redux'
import reducers from './reducers'
import DevTools from './DevTools'
import { AppContainer } from 'react-hot-loader'
import debounceFormChangeActions from './debounceFormChangeActions'
import computeThemeColours from './components/themeColours'
import { getIframeOption, getUrl } from './utils'
import App from './containers/App.dev'
let initialStore = {
iframe: getUrl().includes('iframe'),
themeColours: computeThemeColours(getIframeOption('couleur'))
}
let enhancer = compose(
applyMiddleware(debounceFormChangeActions()),
DevTools.instrument()
)
let store = createStore(reducers, initialStore, enhancer)
let anchor = document.querySelector('#js')
render(<App store={store} />, anchor)
// Hot react component reloading. Unstable but helpful.
if (module.hot) {
module.hot.accept('./containers/App.dev', () => {
render(
<AppContainer>
<App store={store} />
</AppContainer>,
anchor
)
})
}
export { anchor }

View File

@ -1,42 +1,3 @@
import React from 'react'
import { render } from 'react-dom'
import { compose, createStore, applyMiddleware } from 'redux'
import App from './containers/App'
import reducers from './reducers'
import DevTools from './DevTools'
import { AppContainer } from 'react-hot-loader'
import debounceFormChangeActions from './debounceFormChangeActions'
import computeThemeColours from './components/themeColours'
import { getIframeOption, getUrl } from './utils'
let initialStore = {
iframe: getUrl().includes('iframe'),
themeColours: computeThemeColours(getIframeOption('couleur'))
}
let createStoreWithMiddleware = applyMiddleware(debounceFormChangeActions())(
createStore
)
let store = createStoreWithMiddleware(
reducers,
initialStore,
compose(DevTools.instrument())
)
let anchor = document.querySelector('#js')
render(<App store={store} />, anchor)
// Hot react component reloading. Unstable but helpful.
if (module.hot) {
module.hot.accept('./containers/App', () => {
render(
<AppContainer>
<App store={store} />
</AppContainer>,
anchor
)
})
}
export { anchor }
if (process.env.NODE_ENV === 'production')
module.exports = require('./entry.prod')
else module.exports = require('./entry.dev')

28
source/entry.prod.js Normal file
View File

@ -0,0 +1,28 @@
import React from 'react'
import { render } from 'react-dom'
import { compose, createStore, applyMiddleware } from 'redux'
import reducers from './reducers'
import debounceFormChangeActions from './debounceFormChangeActions'
import computeThemeColours from './components/themeColours'
import { getIframeOption, getUrl } from './utils'
import { Provider } from 'react-redux'
import Layout from './containers/Layout'
let initialStore = {
iframe: getUrl().includes('iframe'),
themeColours: computeThemeColours(getIframeOption('couleur'))
}
let enhancer = compose(applyMiddleware(debounceFormChangeActions()))
let store = createStore(reducers, initialStore, enhancer)
let anchor = document.querySelector('#js')
render(
<Provider store={store}>
<Layout />
</Provider>,
anchor
)
export { anchor }