The webpack setup in stock create-react-app supports this:
import customers from ‘./customers.json’
This is a very handy thing and I have come to rely upon it.
@StokeMasterJack
I guess, this repo is a show case of the react / redux / typescript
The webpack configuration is done in create-react-app (from facebook incubator) and / or react-scripts-ts
you might want to close the issue here and create it around this one:
If anyone else is running into this, the following worked for me:
const data = require('./data.json');
As far as I can tell, the TypeScript compiler doesn't know how to handle JSON out of the box. Webpack (which this repo uses) does, so switching to a variable declaration with require() lets webpack take over and load the JSON as normal.
Most helpful comment
If anyone else is running into this, the following worked for me:
const data = require('./data.json');As far as I can tell, the TypeScript compiler doesn't know how to handle JSON out of the box. Webpack (which this repo uses) does, so switching to a variable declaration with
require()lets webpack take over and load the JSON as normal.