Home > Enterprise >  Nuxt.js Full Static - Where to store app configuration file
Nuxt.js Full Static - Where to store app configuration file

Time:09-18

I am using Nuxt.js for my web applications but never used the full static generator until now. My CI/CD pipeline builds and deploys a docker image containing of an nginx image with the static generated Nuxt.js app. My problem now is that I can not figure out how to use and load an app configuration file. Of course I could define all environment variables (like API_URL) during the build process but then i would have to separate images for each environment which would be unfortune.

My approach that I have in mind would be creating a config.json file and maybe having nginx deal with that but how can I tell my web application where he should look for the settings file?

My guess is that maybe people using webpack have come around this problem and know how to deal with it.

CodePudding user response:

I have tried to look into this before.
The TLDR is that you cannot have on-runtime variables for the target: static build, especially with the way how some modules are made.

More info on this Github issue: https://github.com/nuxt/nuxt.js/issues/5100
So yeah, it comes down to have some dynamic webpack configs via your CI/CD, this is how my team handles it at least.

  • Related