B
B
Bogdan2018-03-21 21:49:37
Vue.js
Bogdan, 2018-03-21 21:49:37

Constants and mode of operation?

Hello. Tell me please. I have project constants, I keep them in the variables.js file and include them as needed. But now there was a need to make some of the constants different depending on which mode I'm working in. What is the best way to do this, otherwise the usual way is not very
variables.js

const isProd = ( ) => process.env.NODE_ENV === 'production';

export const urlApi = isProd ? 'http://localhost:3000' : 'http://172.33.27.11:8090';
export const val1 = isProd ? 1 : 2;
export const val1 = isProd ? 1 : 2;
export const val2 = isProd ? 1 : 2;
export const val3 = isProd ? 1 : 2;
export const val4 = isProd ? 1 : 2;
export const val5 = isProd ? 1 : 2;
export const val6 = isProd ? 1 : 2;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-03-21
@Sanasol

https://www.npmjs.com/package/dotenv
And configure normally under the config environment.
Without these isProds a thousand times in the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question