Coralite CLI
This technical documentation provides an in-depth overview of the Coralite CLI, its command-line options, and usage examples.
Command Structure #
The basic command structure for the Coralite CLI is as follows:
coralite [options]
Options #
The Coralite CLI accepts several options to configure its behavior. Here's a detailed list of available options:
-
-c, --components <path>(required)- Description: The file system path to the directory containing Coralite component files.
- Example:
--components path/to/components
-
-p, --pages <path>(required)- Description: The file system path to the directory containing page files that will be rendered.
- Example:
--pages path/to/pages
-
-o, --output <path>(required)- Description: The output directory for the generated site. If the specified directory does not exist, it will be created.
- Example:
--output path/to/dist
-
-m, --mode <mode>(optional)- Description: The build mode. Can be
"production"or"development". Default is"production". - Example:
--mode development
- Description: The build mode. Can be
-
-i, --ignore-attribute <key=value...>(optional)- Description: Ignore elements by attribute name-value pair during parsing. Multiple pairs can be provided separated by spaces.
- Examples:
- Ignore
<div data-ignore>elements:--ignore-attribute data-ignore=true - Ignore multiple elements:
--ignore-attribute data-ignore=true class=test-only
- Ignore
-
-s, --skip-render-attribute <key...>(optional)- Description: Parse elements but exclude them from final render output based on attribute presence.
- Example:
--skip-render-attribute data-client-only
-
-d, --dry-run(optional)- Description: Run the CLI in dry-run mode. This displays information about generated documents and their content without actually writing files to the output directory.
- Example:
coralite -c src/components -p src/pages -o dist --dry-run
-
-a, --assets <mapping...>(optional)- Description: Static assets to copy during build. Supports both NPM packages and local paths. Multiple mappings can be provided separated by spaces. CLI assets override config assets if they target the same destination.
- Formats:
- NPM Package (3 parts):
pkg:path:dest - Local Path (2 parts):
src:dest(source path must start with.,.., or/)
- NPM Package (3 parts):
- Examples:
- Copy from package:
--assets my-package:dist/style.css:assets/style.css - Copy local file:
--assets ./src/logo.png:assets/logo.png - Copy local directory:
--assets ./src/docs:docs
- Copy from package:
Configuration File Support #
The Coralite CLI automatically looks for a coralite.config.js file in the current working directory. If found, it will merge its configuration with the CLI options.
Examples #
1. Generate a site with default options:
coralite -c src/components -p src/pages -o dist
2. Ignore specific elements during parsing and run in dry-run mode:
coralite -c src/components -p src/pages -o dist --ignore-attribute data-ignore=true class=test-only --dry-run
3. Using with a configuration file:
When a coralite.config.js file exists in your project the CLI will automatically load it:
coralite -c src/components -p src/pages -o dist