ReLaXed
ReLaXed copied to clipboard
Load JSON and listen to changes?
I create a PUG that loads a JSON file. The problem is that relaxedjs does not update when I make changes to this file.
Here's the PUG that loads a JSON file:
-
const fs = require('fs');
const data = JSON.parse(fs.readFileSync("./my.json"));
section
p #{data.foo}
when I make changes to my.json
, the console reports No process defined for file /my.json.
and does NOT rebuild the document.
Hi @frankandrobot
const data = JSON.parse(fs.readFileSync("./my.json"));
This reads only once in NodeJS.
The file watching should work when you use the relaxed
binary. When you use it as Node module you have to adjust your code.
https://github.com/RelaxedJS/ReLaXed/tree/master/test/samples/pug/data_require
https://github.com/RelaxedJS/ReLaXed/blob/master/README.md#getting-started
Still not working... The problem is that it still reads the file fine on load but then does not scan for changes. If you make a change to file.json
, it still says No process defined for file /file.json
. What version of relaxed does this apply to?
npx relaxed file.pug -t ./
-
const path = require('path');
const data = require(path.join(basedir, 'file.json'));
section
p #{data.foo}
UPDATE: upgraded to latest 0.2.4 and still seeing the same behavior, node version = 8.15.1