#TypeScript Build Directory issue

6 messages · Page 1 of 1 (latest)

coarse forum
#

Hello! So i have set my tsconfig.json to build to a new folder called _dist. Only issue is i have a top level serviceAccountKey.json that my files require to initialize my database. Unfortunately a side effect is that it creates a copy of that serviceAccountKey.json and also recreates the src folder within the _dist folder as well. I was wondering if there was a setting to fix this or a problem in my implementation. The result i want is within the _dist directory there is no src folder (obviously lol) and no serviceAccountKey.json.

brazen ferry
#

If it's mirroing your src directory that's because you're importing things from outside your source directory into your project so that becomes your root directory.

#

You can explicitly set a rootDir in your tsconfig: e.g. rootDir: "src" and that will preven the _dist/src structure... but it'll just error on all the places where you're importing from outside of src and you'll have to change it.

#

You could look into some other approach for loading that data, like environment variables

coarse forum
#

very helpful! I was thinking bout just using an enviornment variable but wanted to see the reasoning behind this first

#

thanks @brazen ferry ! I think i can take it from here