From a59cf9e7084f1f23cbee1e2c393749f982241fe6 Mon Sep 17 00:00:00 2001 From: Alexandre Hajjar Date: Thu, 11 Feb 2021 19:46:51 +0100 Subject: [PATCH] Redux tracing env variable --- CONTRIBUTING.md | 7 +++++++ mon-entreprise/source/Provider.tsx | 13 +++++++++++-- mon-entreprise/webpack.dev.js | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35a6b4818..627f12dfe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,6 +45,13 @@ yarn start L'application est exécuté sur https://localhost:8080/mon-entreprise pour la version française et http://localhost:8080/infrance pour la version anglaise. +Pour activer le tracing Redux: + +``` +REDUX_TRACE=true yarn start +``` + + ### Messages de commit A mettre sans retenue dans les messages de commit : diff --git a/mon-entreprise/source/Provider.tsx b/mon-entreprise/source/Provider.tsx index 7d4b88e0e..17ea9d6ec 100644 --- a/mon-entreprise/source/Provider.tsx +++ b/mon-entreprise/source/Provider.tsx @@ -18,8 +18,17 @@ declare global { __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any } } - -const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose +if (process.env.REDUX_TRACE) { + console.log('going to trace') +} +const composeEnhancers = + (process.env.REDUX_TRACE + ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ && + window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ + trace: true, + traceLimit: 25, + }) + : window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose if ( process.env.NODE_ENV === 'production' && diff --git a/mon-entreprise/webpack.dev.js b/mon-entreprise/webpack.dev.js index a2e2b8f9e..c0c8b51bb 100644 --- a/mon-entreprise/webpack.dev.js +++ b/mon-entreprise/webpack.dev.js @@ -19,7 +19,10 @@ module.exports = { plugins: [ ...common.plugins, ...HTMLPlugins(), - new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }), + new webpack.EnvironmentPlugin({ + NODE_ENV: 'development', + REDUX_TRACE: false, + }), new webpack.HotModuleReplacementPlugin(), ], }