Installation
First things first, you will need at least node version 18.8.0 and above installed.
After initialising your project, install coralite as a dev dependency:
npm install --save-dev coralite
ECMAScript Modules
Coralite depends on ECMAScript Modules which is only available with the
--experimental-vm-modules
command flag enabled
There are two ways to add this command flag
Set the command flag after running node:
node --experimental-vm-modules node_modules/coralite/bin/coralite
Or set flag via environment variable. If you are running windows, use cross-env to be able to set environment variables, otherwise use the following:
NODE_OPTIONS="--experimental-vm-modules" coralite
Build options
- -t or --templates: The path to your templates directory containing reusable UI elements (e.g., -t ./src/templates).
- -p or --pages: The path to your pages directory where static HTML files reside (e.g., -p ./src/pages).
- --output or -o: The output directory for the generated site (e.g., --output ./dist).
Build script
To prepare the development environment, we'll add the build command to the "script" property in our package.json
file.
Here is an example of what your package.json
file should look like
{
"name": "my-coralite-site",
"scripts": {
"build": "NODE_OPTIONS="--experimental-vm-modules" coralite -t src/templates -p src/pages -o dist"
},
"devDependencies": {
"coralite": "^0.6.2"
}
}
Next, follow the getting started guide to discover how build your first web page with coralite!