Menu icon Foundation
Panini is not compiling json changes in refresh

I am using Foundation 6 and panini for assembling pages, partials and data into pages. Any change I make to js, css or html refreshes immediately in the browser (great!!) except for when I make data changes to the json files in the data folder. In order to see any of those changes I have to restart foundation watch all over again which is a big hassle because it takes forever. Is there any kind of fix for this issue? Seems like a genuine bug to me and I can't find anything about it anywhere.

Thanks.

foundation 6panini

I am using Foundation 6 and panini for assembling pages, partials and data into pages. Any change I make to js, css or html refreshes immediately in the browser (great!!) except for when I make data changes to the json files in the data folder. In order to see any of those changes I have to restart foundation watch all over again which is a big hassle because it takes forever. Is there any kind of fix for this issue? Seems like a genuine bug to me and I can't find anything about it anywhere.

Thanks.

Rafi Benkual about 3 years ago

Hi Paula,

Not sure if this a bug since the Gulpfile can be configured to watch those files. There are a lot of files that are not watched by default to speed up the writing each time the files are saved.

There is a `function watch` in the gulpfile to add this in.

 

Krisztina Toth about 3 years ago

Thank you for your input Rafi. I'm facing the same problem as Paula.

My watch function is set up accurately [it looks for any change in the data folder], and I can see that the relevant tasks run each time I save my json file. However the data is not refreshed in the resulting html file. I can't tell if this is a bug, or the json file needs to be specified explicity as a target in the Gulpfile, but I would think this is enough to do the trick:

gulp.watch(['src/{layouts,partials,helpers,data}/**/*'], ['pages:reset']);

Unfortunately it isn't.

Any thoughts as to why not?

 

Additionally, if I create my data in a .yml file all is working perfectly, so it must be something related to json files.

Thank you.

 

Paula Hightower about 3 years ago

I tried adding this line to the watch function but it did not help:

 

gulp.watch('src/data/*.json', gulp.series(resetPages, pages, customAssemble, browser.reload));

 

as a side note, I posted this reply a few days ago but somehow it never got posted.

Toby Stokes about 3 years ago

I concur that this is related to json data only, yml reloads as expected.

I can see gulp is calling the resetPages function when the .json file changes though.

(fwiw, I just converted my json file to yaml using http://jsontoyaml.com/ as a workaround!)

 

Karl Hand almost 3 years ago

Has anyone found a fix for the json data not being passed on when edited?

I need to restart gulp each time I make changes on a json file.

Frej Nielsen almost 3 years ago

I had this problem too, and it seems to be require caching the files. I got around it by deleting the cache for json and js files before loading them. See https://github.com/zurb/panini/pull/82

Vivek Roy almost 2 years ago

This should help, even though it is about nunjucks.

https://stackoverflow.com/questions/35456748/gulp-nunjucks-html-gulp-data-not-compiling-on-watch

Ehren Coker almost 2 years ago

I was able to get this working by updating the gulpfile

gulp.watch(['../scss/**/*.scss', 'src/assets/scss/**/*.scss', 'src/data/*']).on('all', gulp.series(resetPages, sass, pages, inline, browser.reload));

The resetPages function clears the panini cache, so I just added the data folder to the list of watched folders for the sass tasks.