react-redux-starter-kit icon indicating copy to clipboard operation
react-redux-starter-kit copied to clipboard

Add application configuration based on build environment

Open thomasthiebaud opened this issue 7 years ago • 5 comments

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

thomasthiebaud avatar Oct 19 '16 16:10 thomasthiebaud

Codecov Report

Merging #1053 into master will increase coverage by 1.55%. The diff coverage is 100%.

@@            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.

codecov-io avatar Oct 19 '16 16:10 codecov-io

Does someone checked this PR ?

thomasthiebaud avatar Nov 03 '16 20:11 thomasthiebaud

@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!

dvdzkwsk avatar Nov 03 '16 21:11 dvdzkwsk

I just rebased this PR, so it is up-to-date

thomasthiebaud avatar Mar 22 '17 15:03 thomasthiebaud

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?

kbariotis avatar May 08 '17 08:05 kbariotis