-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔥 fusionne les deux fichiers entry.prod et entry.dev dans un seul fic…
…hier On veut éviter de se répeter (DRY)
- Loading branch information
Johan Girod
committed
May 24, 2018
1 parent
e1a4170
commit 22e51c5
Showing
4 changed files
with
84 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,84 @@ | ||
if (process.env.NODE_ENV === 'production') | ||
module.exports = require('./entry.prod') | ||
else module.exports = require('./entry.dev') | ||
/* global process: false */ | ||
|
||
import ReactPiwik from 'Components/Tracker' | ||
import { rules, rulesFr } from 'Engine/rules' | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import { AppContainer } from 'react-hot-loader' | ||
import { Provider } from 'react-redux' | ||
import { applyMiddleware, compose, createStore } from 'redux' | ||
import DevTools from './DevTools' | ||
import computeThemeColours from './components/themeColours' | ||
import Layout from './containers/Layout' | ||
import lang from './i18n' | ||
import debounceFormChangeActions from './middlewares/debounceFormChangeActions' | ||
import trackDomainActions from './middlewares/trackDomainActions' | ||
import reducers from './reducers/reducers' | ||
import { | ||
persistSimulation, | ||
retrievePersistedSimulation | ||
} from './storage/persist' | ||
import { getIframeOption, getUrl } from './utils' | ||
|
||
let tracker = { | ||
push: console.log, | ||
connectToHistory: history => history | ||
} | ||
if (process.env.NODE_ENV === 'production') { | ||
tracker = new ReactPiwik({ | ||
url: 'stats.data.gouv.fr', | ||
siteId: 39, | ||
trackErrors: true | ||
}) | ||
} | ||
if (process.env.NODE_ENV === 'production') { | ||
let integratorUrl = getIframeOption('integratorUrl') | ||
ReactPiwik.push([ | ||
'setCustomVariable', | ||
1, | ||
'urlPartenaire', | ||
decodeURIComponent(integratorUrl || 'https://embauche.beta.gouv.fr'), | ||
'visit' | ||
]) | ||
} | ||
|
||
let initialStore = { | ||
iframe: getUrl().includes('iframe'), | ||
themeColours: computeThemeColours(getIframeOption('couleur')), | ||
previousSimulation: retrievePersistedSimulation() | ||
} | ||
|
||
let enhancer = compose( | ||
process.env.NODE_ENV !== 'production' | ||
? DevTools.instrument({ maxAge: 10 }) | ||
: x => x, | ||
applyMiddleware(debounceFormChangeActions(), trackDomainActions(tracker)) | ||
) | ||
|
||
let initialRules = lang == 'en' ? rules : rulesFr | ||
let store = createStore(reducers(initialRules), initialStore, enhancer) | ||
let anchor = document.querySelector('#js') | ||
persistSimulation(store) | ||
|
||
let App = ({ store }) => ( | ||
<Provider store={store}> | ||
<> | ||
<Layout tracker={tracker} /> | ||
{process.env.NODE_ENV !== 'production' && <DevTools />} | ||
</> | ||
</Provider> | ||
) | ||
|
||
render(<App store={store} />, anchor) | ||
|
||
if (process.env.NODE_ENV !== 'production' && module.hot) { | ||
module.hot.accept('./containers/Layout', () => { | ||
render( | ||
<AppContainer> | ||
<App store={store} /> | ||
</AppContainer>, | ||
anchor | ||
) | ||
}) | ||
} | ||
export { anchor } |
This file was deleted.
Oops, something went wrong.