Created by: dblazheski96
Summary
Add support for a new environment variables, ENTRY_PATH
and PUBLIC_PATH
, which may be used to override the default entry point src/index
and the default public path public
. It opens new possiblities for developing mini-apps within a container app without actually doing eject
, hence almost config-less micro-frontend architecure.
Configuring
PUBLIC_PATH
will also update theindex.html
path respectively
Benefits
- The default behaviour is persisted.
- Can be configuired for a different entry point if you like it.
- Can be configuired for a different public path if you like it.
- Not doing
eject
for just a couple of paths (keeping thepackage.json
clean)
If developing mini-apps are in mind
- Shared resources, all in one container app (configurations, rule-sets and even components)
- Great overview of the whole project
- Can be used in CI/CD build piplines
- Again not doing
eject
Examples
-
ENTRY_PATH
configured for each mini-app{ "scripts": { "start": "ENTRY_PATH=src/customer/index react-scripts start", "start:business": "ENTRY_PATH=src/business/index react-scripts start", "start:admin": "ENTRY_PATH=src/admin/index react-scripts start", }, }
ENTRY_PATH
can be used in conjunction withBUILD_PATH
for a nicer output structure{ "scripts": { "build": "ENTRY_PATH=src/customer/index BUILD_PATH=build/customer react-scripts build", "build:business": "ENTRY_PATH=src/business/index BUILD_PATH=build/business react-scripts build", "build:admin": "ENTRY_PATH=src/admin/index BUILD_PATH=build/admin react-scripts build", } }
PUBLIC_PATH
used in conjunction withENTRY_PATH
andBUILD_PATH
{ "scripts": { "build": "ENTRY_PATH=src/customer/index PUBLIC_PATH=public/customer BUILD_PATH=build/customer react-scripts build", "build:business": "ENTRY_PATH=src/business/index PUBLIC_PATH=public/business BUILD_PATH=build/business react-scripts build", "build:admin": "ENTRY_PATH=src/admin/index PUBLIC_PATH=public/admin BUILD_PATH=build/admin react-scripts build", } }
-
on: push: branches: - main paths-ignore: - 'src/customer/**' - 'src/admin/**' <!-- rest of configuration --> env: ENTRY_PATH: src/business/index PUBLIC_PATH: public/business BUILD_PATH: build/business
For this workflow example, only the default
build
script inpackage.json
is necessary, others can be used for development purposes.{ "scripts": { "build": "react-scripts build", "build:customer": "ENTRY_PATH=src/customer/index PUBLIC_PATH=public/customer BUILD_PATH=build/customer react-scripts build", "build:business": "ENTRY_PATH=src/business/index PUBLIC_PATH=public/business BUILD_PATH=build/business react-scripts build", "build:admin": "ENTRY_PATH=src/admin/index PUBLIC_PATH=public/admin BUILD_PATH=build/admin react-scripts build", } }
-