-
Notifications
You must be signed in to change notification settings - Fork 4
Preparing for deployment to Ontario.ca
npm run build
will generate the application in the dist
directory (after removing it to ensure a clean build). This directory can then be deployed to a suitable hosting environment for serving static content.
For values that need to differ between environments, the basic approach described in the Eleventy documentation has been used has been used. This lets you do the following:
- when building:
ELEVENTY_ENV=stage npm run build
- sets the build environment to stage or another value - in templates:
{{ globals.environment }}
to access the supplied value ofELEVENTY_ENV
(defaults todevelopment
if no value supplied) - in
_data/globals.js
: use theenv
value inmodule.exports
to implement environment-differentiated variables or functions to supply to your templates- The
userFriendlyEnvString
values provides a simple example of how to do this
- The
Jamstack sites deployed to Ontario.ca will need a configured site root based on their deployment subfolder. The siteRootEnvs
object in src/_data/app/app-globals.js
can be used for these purposes.
Eleventy can be configured to build site outputs that are different from the source input by modifying options in the .eleventy.js
configuration file, which is made up of a combination of configuration functions and options in two files:
-
.app-eleventy.js
(a point for your application's configuration) -
.core-eleventy.js
(core configuration, do not modify)
The default state of the toolkit shows some examples of this approach that aligns with deploying Jamstack sites to Ontario.ca:
- The
addPassthroughCopy
statement in.app-eleventy.js
copies the root-level assets folder insrc
to thejamstack-toolkit
folder of the built site - The
assetsPath
variable fromsrc/_data/app/app-globals.js
is used to reference the build location of the assets folder in the templates
This configuration simplifies deployment to Ontario.ca by requiring only two routes to be configured (one for each language) with an assets directory shared between the two.