20 Package and Deploy Oracle JET Apps

If you used Oracle JET tooling to create your Oracle JET app, you can package web apps for deployment to a web or app server.

Package Web Apps

If you created your app using the tooling, use the Oracle JET command-line interface (CLI) to create a release version of your app containing your app scripts and applicable Oracle JET code in minified format.

  1. From a terminal prompt in your app’s root directory, enter the following command: ojet build --release.

    The command will take some time to complete. When it’s successful, you’ll see the following message: Build finished!.

    The command replaces the development version of the libraries and scripts in web/js/ with minified versions where available.

  2. To verify that the app still works as you expect, run ojet serve with the release option.

    The ojet serve --release command takes the same arguments that you used to serve your web app in development mode.

    ojet serve --release [--serverPort=server-port-number --serverOnly]

    Tip:

    For a complete list of options, type ojet help serve at the terminal prompt.

Deploy Web Apps

Oracle JET is a collection of HTML, JavaScript, and CSS files that you can deploy to any type of web or app server. There are no unique requirements for deploying Oracle JET apps.

Deployment methods are quite varied and depend upon the type of server environment your app is designed to run in. However, you should be able to use the same method for deploying Oracle JET apps that you would for any other client interface in your specific environment.

For example, if you normally deploy apps as zip files, you can zip the web directory and use your normal deployment process.

Remove and Restore Non-Source Files from Your JET App

The Oracle JET CLI provides commands (clean, strip, and restore) that manage the source code of your JET app by removing extraneous files, such as the build output for the platforms your JET app supports or npm modules installed into your project.

Consider using these commands when you want to package your source code for distribution to colleagues or others who may work on the source code with you. Use of these commands may not be appropriate in all circumstances. Use of the clean and strip commands will, for example, remove the content in the web directory that is created when you run ojet build or ojet serve.

ojet clean

Use the ojet clean command to clean the build output of your JET app. Specify the web parameter with the ojet clean command (ojet clean web) to remove the contents of your app’s root directory’s web directory.

ojet strip

Use ojet strip when you want to remove all non-source files from your JET app. In addition to the build output removed by the ojet clean command, ojet strip removes additional dependencies, such as npm modules installed into your project. A typical usage scenario for the ojet strip command is when you want to distribute the source files of your JET app to a colleague and you want to reduce the number of files to transmit to the minimum.

The ojet strip command relies on the presence of the .gitignore file in the root directory of your app to determine what to remove. The file lists the directories that are installed by the tooling and can therefore be restored by the tooling. Only those directories and files listed will be removed when you run ojet clean on the app folder.

If you do not use Git and you want to run ojet strip to make a project easier to transmit, you can create the .gitignore file and add it to your app's root folder with a list of the folders and files to remove, like this:

#List of web app folders to remove
/node_modules
/bower_components
/themes
/web

As an alternative to the .gitignore file, you can include a stripList property that takes an array of glob pattern values in your app's oraclejetconfig.json file. When you specify the stripList parameter in the oraclejetconfig.json file, Oracle JET ignores the .gitignore file and its entries. Specify the list of directories and file types that you want to remove when you run ojet strip, as demonstrated by the following example.

{
. . .
  "generatorVersion": "15.1.0",
  "stripList": [
    "jet_components",
    "node_modules",
    "bower_components",
    "dist",
    "web",
    "staged-themes",
    "themes",
    "myfiles/*.txt"
  ]
}

ojet restore

Use the ojet restore command to restore the dependencies, plugins, libraries, and Web Components that the ojet strip command removes. After the ojet restore command completes, use the ojet build and/or ojet serve commands to build and serve your JET app.

The ojet restore command supports a number of additional parameters, such as ojet restore --ci that invokes the npm ci command instead of the default npm install command. This option (ojet restore --ci) fetches the dependencies specified in the package-lock.json file, and can be useful in CI/CD pipelines.

For additional help with CLI commands, enter ojet help at a terminal prompt.