diff --git a/.env.development b/.env similarity index 73% rename from .env.development rename to .env index 062b97107..6f5a2f3bd 100644 --- a/.env.development +++ b/.env @@ -1,7 +1,7 @@ ## -# DEVELOPMENT: Default +# Environment: Default # -# We're using this to set variables for our local development. +# We're using this to set variables for development. # Please feel free to delete or modify this file for your own setup. # Be careful not to commit anything sensitive to source control. # diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..d179308f1 --- /dev/null +++ b/.env.example @@ -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 diff --git a/.env.production b/.env.production deleted file mode 100644 index 464ee6dc5..000000000 --- a/.env.production +++ /dev/null @@ -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 diff --git a/docs/latest/deployment/recipes/build-for-production.md b/docs/latest/deployment/recipes/build-for-production.md index 6ab01c731..20864d125 100644 --- a/docs/latest/deployment/recipes/build-for-production.md +++ b/docs/latest/deployment/recipes/build-for-production.md @@ -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 diff --git a/package.json b/package.json index 68929a2ae..2e98caa5c 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,9 @@ "dev": "yarn run preBuild && cross-env PORT=5000 react-scripts start", "dev:debug": "cross-env PORT=5000 react-scripts start", "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:package:ci": "yarn run preBuild && 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", diff --git a/src/utils/initWebWorkers.js b/src/utils/initWebWorkers.js index 1de094071..26ec6ca2b 100644 --- a/src/utils/initWebWorkers.js +++ b/src/utils/initWebWorkers.js @@ -6,7 +6,9 @@ import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader' * @param {String} webWorkScriptsPath */ export default function(baseDirectory, webWorkScriptsPath) { - const scriptsPath = `${baseDirectory}/${webWorkScriptsPath}` + const scriptsPath = `${window.location.protocol}//${ + window.location.host + }${baseDirectory}/${webWorkScriptsPath}` const config = { maxWebWorkers: Math.max(navigator.hardwareConcurrency - 1, 1), startWebWorkersOnDemand: true,