Answer the question
In order to leave comments, you need to log in
How is it better to export settings from a file in Node, what are the rules?
Now:
// Настройки по умолчанию
var configDefault = {
hello: "i dont understand",
bye: "bye"
}
try {
const configFile = require('./config');
if(typeof gulpconfigFile === "object")
var gulpconfig = Object.assign({}, configDefault, configFile)
} catch(e) {
var config = configDefault;
}
Answer the question
In order to leave comments, you need to log in
There is a powerful package: https://www.npmjs.com/package/config.
On your knee, you can simply create default.js, production.js, test.js and local.js, read require
them from each other as needed and overwrite properties using Object.assign (that is, approximately as you have), and from index .js include the one you need, based on the environment variables.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question