react-redux-starter-kit
react-redux-starter-kit copied to clipboard
Add application configuration based on build environment
This is a PR related to this issue #160
The main idea is to define an alias into webpack.config.js
which pointed to the right config file.
It is then as simple as
import config from `config`
config.my_variable
to access the variable
Codecov Report
Merging #1053 into master will increase coverage by
1.55%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #1053 +/- ##
==========================================
+ Coverage 72.72% 74.28% +1.55%
==========================================
Files 12 15 +3
Lines 66 70 +4
==========================================
+ Hits 48 52 +4
Misses 18 18
Impacted Files | Coverage Δ | |
---|---|---|
src/config/test.js | 100% <100%> (ø) |
|
src/config/development.js | 100% <100%> (ø) |
|
src/routes/Home/components/HomeView.js | 100% <100%> (ø) |
:arrow_up: |
src/config/production.js | 100% <100%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update fd16e16...1448a52. Read the comment docs.
Does someone checked this PR ?
@thomasthiebaud I'm just getting back into the swing of this project. I've glanced at it, and appreciate the contribution, but it may take me a day or two to come back to considering it more thoroughly. Sorry for the delay!
I just rebased this PR, so it is up-to-date
Hello there @thomasthiebaud. Using the alias command means that the imported object will be included as is in the generated assets. Isn't this a problem because even the values that are not being used will be exposed to the consumer.
I am using DefinePlugin to expose environment based configuration to my app, which is being evaluated in compile time and exposes only the required values. Furthermore, I am defining feature toggles (simple booleans) on my configurations where if the toggle is false, UglifyJS will drop the dead code. Neat feature!
Would you consider a DefinePlugin based solution?