Set ENV variables in scripts instead of in build
This commit is contained in:
parent
33d06dba4e
commit
81cf8cbd7c
13
.env.example
Normal file
13
.env.example
Normal file
@ -0,0 +1,13 @@
|
||||
##
|
||||
# EXAMPLE
|
||||
#
|
||||
# Read more about .env files when using create-react-app here:
|
||||
# https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#adding-development-environment-variables-in-env
|
||||
#
|
||||
|
||||
PUBLIC_URL=/demo
|
||||
|
||||
#
|
||||
# Most vars require REACT_APP_* naming
|
||||
#
|
||||
REACT_APP_CONFIG=config/netlify.js
|
||||
@ -1,14 +0,0 @@
|
||||
##
|
||||
# PRODUCTION: Netlify
|
||||
#
|
||||
# We're using this to set variables for our Netlify deploy.
|
||||
# Please feel free to delete or modify this file for your own production
|
||||
# environment. Be careful not to commit anything sensitive to source control.
|
||||
#
|
||||
|
||||
PUBLIC_URL=/demo
|
||||
|
||||
#
|
||||
# Most vars require REACT_APP_* naming
|
||||
#
|
||||
REACT_APP_CONFIG=config/netlify.js
|
||||
@ -70,15 +70,18 @@ how to configure the project for your own imaging archive below.
|
||||
> ["Set up a local DICOM server"](./../../essentials/getting-started.md#set-up-a-local-dicom-server),
|
||||
> or a deployment recipe that contains an open source Image Archive
|
||||
|
||||
#### How It Works
|
||||
#### How it Works
|
||||
|
||||
The configuration for our project is in the `/public/config` directory. Our
|
||||
build process knows which configuration file to use based on the
|
||||
`REACT_APP_CONFIG` environment variable. By default, its value is
|
||||
[`default.js`](https://github.com/OHIF/Viewers/blob/react/public/config/default.js).
|
||||
When we build, the `%REACT_APP_CONFIG%` value in
|
||||
our[`/public/index.html`](https://github.com/OHIF/Viewers/blob/react/public/index.html#L12-L15)`file is substituted for the correct configuration file's name. Ultimately setting the`window.config`
|
||||
equal to our configuration file's value.
|
||||
our[`/public/index.html`](https://github.com/OHIF/Viewers/blob/react/public/index.html#L12-L15)
|
||||
file is substituted for the correct configuration file's name. This sets
|
||||
the`window.config` equal to our configuration file's value.
|
||||
|
||||
#### How do I configure my project?
|
||||
|
||||
- Modify its values directly
|
||||
- Create a new config file, and set the `REACT_APP_CONFIG` environement variable
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
"build:package": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c",
|
||||
"build:package:ci": "yarn run preBuild && cross-env REACT_APP_CONFIG=config/default.js node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c",
|
||||
"build:web": "yarn run preBuild && react-scripts --max_old_space_size=4096 build",
|
||||
"build:web:ci": "yarn run preBuild && react-scripts --max_old_space_size=4096 build && cpx 'build/**/*' docs/latest/_book/demo --verbose",
|
||||
"build:web:ci": "yarn run preBuild && cross-env PUBLIC_URL=/demo REACT_APP_CONFIG=config/netlify.js react-scripts --max_old_space_size=4096 build && cpx 'build/**/*' docs/latest/_book/demo --verbose",
|
||||
"lint": "eslint -c .eslintrc --fix src && prettier --single-quote --write src/**/*.{js,jsx,json,css}",
|
||||
"test": "jest",
|
||||
"test:ci": "jest --ci --runInBand --collectCoverage --reporters=default --reporters=jest-junit && codecov",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user