Skip to content

starkers/react-app-values

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rename strings in files

sorry not had time to document this better..

The problem..

  • Packaging a react app build folder into a docker image sucks
  • Building different variants of this into discrete different directories can only scale so far
  • CI/CD stage needs to execute many (inefficient ) npm run build runs
  • storing different folders that have tiny differences suck

Solution

  1. Run the build once
  2. ensure all REACT_APP_ env vars have consistent values.. EG: REACT_APP_FOO will have the default value of DEFAULT_VALUE_FOO

When booting the container 3. loop over all env vars (eg REACT_APP_FOO) 4. substitute the values inside the files with the env vars of the container

blerb

This tool simply evaluates all ENV vars with the prefix of REACT_APP_ and does some file rewriting..

For example you have the env var REACT_APP_FOO = BAR set The script will:

  • find all files in the subdir
  • rename all strings in the files if they are called DEFAULT_VALUE_FOO

TLDR

  • when adding new REACT_APP_X variables to you files, ensure to build the assets with a default value of DEFAULT_VALUE_X
  • why not a simple bash+sed script? a static binary is better to distribute and safer than shell scripting + distributing shell environments into a container

TODO

  • needs tests
  • ugly exported functions
  • gooder docs

About

rename strings in files based on env vars

Resources

License

Stars

Watchers

Forks

Packages

No packages published