Build for Production
If you've already followed the "Getting Started" Guide, you can skip ahead to Configuration
#
Overview#
Build Machine Requirements#
Getting the CodeWith Git:
# Clone the remote repository to your local machinegit clone https://github.com/OHIF/Viewers.git
More on: git clone
,
git checkout
From .zip:
#
Restore Dependencies & BuildOpen your terminal, and navigate to the directory containing the source files. Next run these commands:
// If you haven't already, enable yarn workspacesyarn config set workspaces-experimental true
// Restore dependenciesyarn install
// Build source code for productionyarn run build
If everything worked as expected, you should have a new dist/
directory in the
project's folder. It should roughly resemble the following:
<root>platform/viewer/dist/โโโ app-config.jsโโโ app.bundle.jsโโโ app.cssโโโ index.htmlโโโ manifest.jsonโโโ service-worker.jsโโโ ...
By default, the build output will connect to OHIF's publicly accessible PACS. If this is your first time setting up the OHIF Viewer, it is recommended that you test with these default settings. After testing, you can find instructions on how to configure the project for your own imaging archive below.
#
ConfigurationThe configuration for our viewer is in the <root>platform/viewer/public/config
directory. Our build process knows which configuration file to use based on the
APP_CONFIG
environment variable. By default, its value is
[config/default.js
][default-config]. The majority of the viewer's features,
and registered extension's features, are configured using this file.
The easiest way to apply your own configuration is to modify the default.js
file. For more advanced cofiguration options, check out our
configuration essentials guide.
#
Next Steps#
Deploying Build OutputDrag-n-drop
Easy
Advanced
#
Testing Build Output LocallyA quick way to test your build output locally is to spin up a small webserver.
You can do this by running the following commands in the dist/
output
directory:
// Install http-server as a globally available packageyarn global add http-server
// Serve the files in our current directory// Accessible at: `http://localhost:8080`http-server
#
Automating Builds and DeploymentsIf you found setting up your environmnent and running all of these steps to be a bit tedious, then you are in good company. Thankfully, there are a large number of tools available to assist with automating tasks like building and deploying web application. For a starting point, check out this repository's own use of:
#
TroubleshootingIssues and resolutions for common GitHub issues will be summarized here
...