Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Add application configuration based on build environment #1053

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add application configuration based on build environment #1053

wants to merge 1 commit into from

Conversation

thomasthiebaud
Copy link

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-io
Copy link

codecov-io commented Oct 19, 2016

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%> (ø) ⬆️
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.

@thomasthiebaud
Copy link
Author

Does someone checked this PR ?

@dvdzkwsk
Copy link
Owner

dvdzkwsk commented Nov 3, 2016

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

@thomasthiebaud
Copy link
Author

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

@kbariotis
Copy link

kbariotis commented May 8, 2017

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants