Roots Discourse

How to read a txt or json file `dist` folder in sage

I need to read some JSON data from a file in my sage Theme.
I created a data folder in resources/assets with two files: myData.txt and myData.json with some JSON data, and modified the resources/assets/build/config.js as the following:

....
const config = merge({
...
  copy: '+(images|data)/**/*',
...

After running yarn start or yarn build or yarn build:production I do have a data folder in dist, and my files are there.
The asset_path('data/specialCases.json') returns the correct URL, but if I visit it, it redirects me to the home-page of my site.
So when I try file_get_contents(asset_path('data/myData.json)), it returns my homepage source.

Well, sage already reads a manifest JSON file, in Sage 9:

return new JsonManifest(config('assets.manifest'), config('assets.uri'));

It was working well, I only had a typo in my filename… :S