Hugo & ESBuild - jsconfig.json is overridden on every launch

Written by Lyoneel on in HUGO, troubleshooting
 1 min

Hugo & ESBuild - jsconfig.json is overridden on every launch

How to avoid jsconfig.json gets overridden every time hugo server starts

I use a custom configuration in my theme, I need to add few additional lines to jsconfig.json. Additions are target and experimentalDecorators, my configuration file looks like this:

{
 "compilerOptions": {
  "baseUrl": ".",
  "paths": {
   "*": [
    "*"
   ]
  },
  "target": "ESNext",
  "experimentalDecorators": true
 }
}

Every time I ran my Hugo server, this file got overridden. It Hugo’s default behavior.

It Is fine to create this file automatically, but it is not fine to overwrite when it exists. To avoid it, you have to add the following line in your config.yml:

build:
  noJSConfigInAssets: true

Now using the new configuration, you will hold old your changes on every server restart. I don’t think this default behavior is correct, or maybe I don’t have enough information to understand it. I may create a PR to fix this if I have the time in the future.