Reading JSON file at runtime #13058
Unanswered
royderegt
asked this question in
CLI - Electron mode
Replies: 2 comments 3 replies
-
|
try lazy-loading or process.env |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Imports are processed on build-time, so you won't be able to properly change the values on runtime. You can use the Knowing all these, you can store your // electron-main or electron-preload
import fs from 'fs'
import path from 'path'
const publicFolder = path.resolve(__dirname, process.env.QUASAR_PUBLIC_FOLDER)
const dataFilePath = path.resolve(publicFolder, './data.json')
const dataContents = fs.readFileSync(dataFilePath, 'utf-8')
const data = JSON.parse(dataContents) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm running a single Quasar build in multiple containers. Depending on the environment, I want certain variables to differ from one another. I tried doing this by adding a
data.jsonfile to the containers and reading the data usingimport DATA from data.json. I've noticed this data is only read once at build time, where I want my application to read this file at runtime. Is there any way to get read this data at runtime?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions