Explicitly include directory in zipball dist folder?

Hi, I’m using the popular config package (config - npm) in my API to configure some variables across environments. I have the config files in a directory located at “api/src/config”. However, when I go to deploy my service, the “packer” (redwood/nft.js at main · redwoodjs/redwood · GitHub) does not include my “config” directory in the zipball “dist” folder. The reason is that the packer uses a “node-file-trace” package to trace a dependency network of only files that it thinks should be included in the “dist” folder. Since I never explicitly import any files directly in my “config” directory (as the package does this for me), the config files are not included. Is there any clean way that I can ensure this directory is included in my zipball? Should I open an issue for this in github?

Hey @dmasters19,

I also responded on Discord. I think the easiest thing to try is to drop the files in

api/src/lib/config or perhaps api/src/lib

Please try that and see if it works. I am not certain, but files in this folder might get bundled without having to be referenced by another file. This might solve the problem without any big changes.

1 Like

@dmasters19 , are you able to get it to work ?

i did try with your suggested config package in redwood but not able to run it successfully.

Hey @fireworks2005 - did you try putting the config in /api/src/lib/config to see if it would work that way?

My thinking stems from: Redwood File Structure | RedwoodJS Docs

  • lib contains a few files:auth.ts starts as a placeholder for adding auth functionality and has a couple of bare-bones functions in it to start, db.ts instantiates the Prisma database client so we can talk to a database and logger.ts which configures, well, logging. You can use this directory for other code related to the API side that doesn’t really belong anywhere else.

Hi @PantheRedEye , finally, i managed to get the node-config package to run in RedwoodJS.

With some observations as follow:

  1. We cant use “import config from ‘config’” to load this package. If not it will ignore the predefined ‘NODE_CONFIG_DIR’ environment variable and load its default value. we have to use “const config = require(config)” to get it work.

  2. This config package will lookup json and yaml files. However, redwoodJs build process will not copy any of the json or yaml files to the dist folder. Reading the json or yaml files will not work for config package. The only workaround is to use JS/ TS file.

Attach screenshot for reference

1 Like