1

I'm wanting to read in JSON files from local disk at runtime after electron-bulder packages up the Windows executable. These files already exist as part of the build itself, and I have set the following to have the JSON files places in a directory that I assumed should be relative to both the development release versions.

"extraFiles": [{
    "from": "./src/json/",
    "to": "json",
    "filter": [
        "**/*"
    ]
}],

When I open my release folder, and check the unpacked files, I see a json folder with my files. I'm currently importing the JSON files in my .ts files using the import * as alias from '@json/jsonFile.json where @json is a defined path in my 'paths' section of tsconfig.json. If I change the JSON file after the release is built and then run the electron application the changes are not being picked up.

Is this because the JSON files get packaged during the electron-build process so that the files I'm dumping out to the json folder are effectively useless? I really would like to be able to give user control over how they update the output JSON files so that there is a level of dynamic control over the data the application processes.

Any help would be extremely appreciated.

Thanks!

  • I't unclear (to me, at least) what your real need is here. Do you just want to read in a JSON file at runtime? – spring Jan 05 '19 at 21:35
  • 1
    Ah, yeah, sorry. I was trying to type it up on my phone at lunch so it's isn't as clear as I'd like. Basically, I have JSON files that are used as data sources that I'd like to make available for update by end users that can be processed during runtime. The path, fs, and __dirname options aren't working, despite @types/node being enabled, so I'm unsure the best approach to take. – Matt McNeely Jan 05 '19 at 22:00

0 Answers0