-4

Using react-app and webpack, I was wondering if it's possible to bundle a config.json file such that you can access it after the site builds and be able to change values within it and have that be reflected on the website. This is mainly so that I can have values in my config.json file like "header__1" or "about__description" in my config.json file and hand them over to my clients so that they may change values themselves w/o having to consult me.

1 Answers1

-3

Welcome to stackoverflow Shaun,

since you're writing a web application with react and it is all about Javascript, you can't work with files like you can with desktop clients. Neither should you (read more here).

If you want your web clients to be modifiable by the customer you should add something like a config page to your app. The values that change should then be stored in the localStorage of the browser or something similar.

EDIT: Of cause a config file could be loaded from an external source. But then you have to differ between users and their individual configurations (which might be not what you want). Files bundled with webpack can't be edited (permanently) on the users side.

Björn Böing
  • 1,662
  • 15
  • 23
  • 1
    Why not? A JSON config is a resource like any other than can be loaded with an ajax call. Localization is one typical use case – Sulthan Dec 31 '18 at 14:43
  • So essentially it's not possible to load a mutable config.json file after building the application with webpack? – Shaun Chander Jan 01 '19 at 00:29