How to conditionally import?
Unanswered
Pudelpointer posted this in #help-forum
PudelpointerOP
I am writing a NextJs project. The project has two environments ~ development and production. The development parameters are in generated_dev.ts file and production parameters are in generated.ts file. The parameters have the same names, so they cannot be put in the same file.
The loading environment depends on "process.env.NEXT_PUBLIC_TESTNET". I do not want to revise the codes when changing environment. How can I write the codes so that when "process.env.NEXT_PUBLIC_TESTNET === 'true'", my .tsx will use "
import { XXX, XXX } from '../generated_dev'" and when "process.env.NEXT_PUBLIC_TESTNET === 'false'", my .tsx will use "
import { XXX, XXX } from '../generated'"?
Thank you very much for your time!
The loading environment depends on "process.env.NEXT_PUBLIC_TESTNET". I do not want to revise the codes when changing environment. How can I write the codes so that when "process.env.NEXT_PUBLIC_TESTNET === 'true'", my .tsx will use "
import { XXX, XXX } from '../generated_dev'" and when "process.env.NEXT_PUBLIC_TESTNET === 'false'", my .tsx will use "
import { XXX, XXX } from '../generated'"?
Thank you very much for your time!