Prepare to deploy an Oracle JET web app
Introduction
This tutorial shows you how to prepare an Oracle JavaScript Extension Toolkit (Oracle JET) web app for deployment.
You can deploy the Oracle JET web app, which contains a collection of HTML, JavaScript, and Cascading Style Sheets (CSS) files, to any type of web or application server. The method of deployment depends upon the type of server environment that your app runs in.
To deploy the Oracle JET web app, you can use the same method that you use to deploy any other client interface in your specific environment.
- If you normally deploy apps as ZIP files, then you can compress the
/web
folder of the web app and follow your standard deployment process. - If you normally deploy apps as WAR files, then you may also need to modify the web app before you generate the archive file of the
/web
folder. For example, to create a.war
file, you include a/WEB-INF
folder that contains aweb.xml
configuration file.
The web app that you create with the Oracle JET command-line interface contains a folder of hook script template files that you can use to define new steps for the build process. For example, you can create a hook script to archive the web app /web
folder as a ZIP file or as a WAR file. This after_build
script runs after the build process finishes.
This tutorial doesn’t illustrate the deployment steps that depend upon a specific environment and platform.
Objectives
In this tutorial, you will learn how to archive the /web
folder of the web app as either a ZIP file or a WAR file. You will also learn how to modify the web app to automate archiving as part of the Oracle JET web app build process.
Prerequisites
- A development environment set up to create Oracle JET web apps that includes an installation of Node.js
- Completion of the previous tutorial in this learning path, Add Unit Tests to an Oracle JET MVVM Web App
- Familiarity with the deployment practices of your environment
Task 1: Create the after_build Hook Script
You create the after_build
hook script by using a provided hook script template file that you modify.
-
Navigate to the
JET_Web_Application/scripts/hooks
directory and open theafter_build.js
hook script template file in an editor. -
Copy the after-build-js.txt code snippet and replace the contents of the template file with the copied code snippet.
Task 2: Modify the after_build Hook Script
Modify the hook script to specify the type of archive file that you want to generate for the web app. The hook script uses the same compression method to create the zip file and the WAR file. You modify the after_build
hook script to specify the extension of the output file, which is .war
by default.
- In the
after_build.js
file, edit the file name passed tofs.createWriteStream()
to use the appropriate extension:.zip
or.war
.-
To generate a WAR file, name the file
my-archive.war
.const output = fs.createWriteStream('my-archive.war');
-
To generate a ZIP file, name the file
my-archive.zip
.const output = fs.createWriteStream('my-archive.zip');
-
- Save the
after_build.js
file without changing the file name. The file names of the hook scripts in the/scripts/hooks
directory correspond to various Oracle JET build hook points.
Task 3: Build the App in Release Mode
When you build the web app in release mode, the build --release
command replaces the development version of the libraries and scripts in the /web/
folder with minified versions. When the build process is completed, the build then executes the after_build
hook script and archives the contents of the /web
folder.
-
Open a terminal window, change to the
JET_Web_Application
directory, and install thearchiver
NPM package.npm install archiver
This installs the
archiver
NPM package in theJET_Web_Application
project. Theafter_build.js
hook uses this package to archive your web app. -
Open a terminal window, change to the
JET_Web_Application
directory, and build the web app in release mode.npx ojet build web --release
The build process triggers hook scripts located in the
/scripts/hooks
directory and takes a few minutes to finish. -
Wait for confirmation.
. . . Running after_build hook. Success: Build finished. Files were successfully archived.
-
Navigate to the
JET_Web_Application
directory and locate the archive file generated by the hook script. For example, if you modified theafter_build
hook script to generate a WAR file namedmy-archive.war
, then a WAR file with that name appears in the app root folder.
Next Step
To proceed to the first tutorial in the next learning path in this series, click here.
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Prepare to deploy an Oracle JET web app
E97510-09
December 2024