For example, I'm trying to export a TS object to get this JavaScript output:
const path = require('path'),
rootPath = path.normalize(__dirname + '/..'),
env = process.env.NODE_ENV || 'development';
let config = {
development: {
amqpUrl: "amqp://localhost:15672",
root: rootPath
},
test: {
amqpUrl: "amqp://localhost:5672",
root: rootPath
},
production: {
amqpUrl: "amqp://localhost:5672",
root: rootPath
}
};
module.exports = config[env];
This is my TS, but it's not clear with exporting,
import path = require("path")
const rootPath = path.normalize(__dirname + '/..')
const env = process.env.NODE_ENV || 'development'
let config = {
development: {
amqpUrl: "amqp://localhost:15672",
root: rootPath
},
test: {
amqpUrl: "amqp://localhost:5672",
root: rootPath
},
production: {
amqpUrl: "amqp://localhost:5672",
root: rootPath
}
};
/* this is the line i'm having problem how can i export config object*/
// export config[env];
I've tried export default config[env]
but its generated output isn't expected. What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…