Thanks for the article, I was struggling with this issue not too long ago. Interesting approach. Personally I used DotEnv plugin for webpack and I saved configuration per environment in .env file. But then it requires different builds (or building on the server and picking right .env file).
What you present here solves the problem, but adds one call before the app can launch.
Since you have to manually (or using some pipeline) replace the file - wouldn't it be easier to build app with parameter? Let's say npm run build --test or npm run build --dev and pass the arguments?
And yes, i think you can develop a npm script to build with the file you want automatically, but i want to just build one time and then, with Jenkins, deploy the right file.
But yes, this can be done in a very different ways.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the article, I was struggling with this issue not too long ago. Interesting approach. Personally I used DotEnv plugin for webpack and I saved configuration per environment in
.env
file. But then it requires different builds (or building on the server and picking right.env
file).What you present here solves the problem, but adds one call before the app can launch.
Since you have to manually (or using some pipeline) replace the file - wouldn't it be easier to build app with parameter? Let's say
npm run build --test
ornpm run build --dev
and pass the arguments?I'm glad it helped you!
And yes, i think you can develop a npm script to build with the file you want automatically, but i want to just build one time and then, with Jenkins, deploy the right file.
But yes, this can be done in a very different ways.