Project is broken by default for new installs due to .env dependency
Closed this issue · 2 comments
We have a dependency on the custom-react-scripts
package which requires the user to have a .env file present at the root of their project directory. If the .env file is not present, then subsequent npm run start
or npm run build
commands will fail. Right now, the only customization we require is to enable support for decorators in the .env file i.e. REACT_APP_DECORATORS=true
. A couple potential solutions:
- Remove .env from .gitignore so it 'just works'
- Add documentation to README explaining the dependency
- Add preinstall script to generate the file the first time the user runs an
npm install
- Update to latest version of create-react-app, eject, and make decorator support the default
@andykog Thoughts?
Approaches 1-3 feel like band-aids. Approach 4 initially struck me as overkill but might have some merit. The reason: I leveraged custom-react-scripts
to get up and running quickly but the project has not been updated in some time. This may present an opportunity to remove an unnecessary dependency on a package that may no longer actively be maintained.
@hodorswit, option 1 seems to be straightforward solution. If your intent is to get rid of custom-react-scripts, maybe it's better to create a minimal clean setup manually instead of ejecting CRA, as it will overcomplicate things?
Agreed that ejecting would over-complicating things. For now, I will go with option 1 because it solves the problem at hand in the simplest way.
Longer term, I'm not against creating a minimal custom webpack setup, but ideally I would like this project to benefit from the incremental advances being made by the create-react-app team. I will look into what it would take to get custom-react-scripts
updated to the latest version and submit a PR, that way other projects can benefit as well.