Description
Hello, I found an easy way to enable additional presets & plugins in my fork of react-scripts. I want to share it with others and the maintainer of this original repository may find this feature useful and add it to the main react-scripts
.
Basically, what I did was just introducing two environment variables BABEL_PRESETS and BABEL_PLUGINS, which accept JSON encoded list of path strings. Users can enable any kind of presets/plugins by specify those two variables before they run npm start
.
For example, I need to enable react-relay
support. What I did is just execute this command before I start the development server:
export BABEL_PLUGINS="[\"`pwd`/plugins/relay-plugin.js\"]"
With my forked react-scripts (@philiptzou/react-scripts
) and other related relay packages installed, the webpack server is able to handle Relay.QL
syntax now.
I just noticed that we can use .env
file to specify REACT_APP_
initial variables. It maybe a more elegant way to do this in the future.