Sunday 16 April 2017

import config file in create-react-app

I have a create-react-app application which I have run npm run eject.

I am trying to add some config details to a config file.

I have created a core.json file that looks like this

{
   "username": "test",
   "pass": "1234",
   "users": ["Chuck", "Phyllis"]
}

In my App.js file I have tried to import this file, but am unable to

import '../../config.core.json';

My project structure looks like this:

Project
|__config
|        |
|        |__core.json
|        |__webpack.config.dev.js
|        |__webpack.config.prod.js
|_node_modules
|_public
|_src|
     |_App.js

Can anyone advise how I can access the users in my App.js file?



via peter flanagan

No comments:

Post a Comment