v 0.1.105

CLI Reference

The Ecopages CLI is the canonical command-line interface for scaffolding, developing, building, and serving Ecopages apps.

Run it with bunx (recommended for one-off usage):

bunx ecopages --help

Or install it in your app and run via scripts:

bun add ecopages

Commands

Ecopages supports app lifecycle and scaffolding commands.

init

Scaffolds a new Ecopages project.

dev

Starts the development server.

dev:watch

Starts the development server with restart-on-change behavior.

dev:hot

Starts the development server with hot reload behavior.

build

Generates a static production build of your project.

preview

Builds your project and starts a local production server for testing.

start

Starts the production server using the existing build in the .eco directory.

Note: Commands that accept [entry] default to app.ts when omitted.


Global Flags

These flags can be appended to any command to override default behavior.

FlagTypeDescription
--devbooleanForces development mode regardless of the command.
--buildbooleanForces build mode regardless of the command.
--previewbooleanForces preview mode regardless of the command.
--react-fast-refreshbooleanEnables React Fast Refresh during development.

Server Flags

These flags are supported by server commands and map to environment variables.

FlagEnvironment VariableDescription
-p, --port ECOPAGES_PORTServer port (default 3000)
-n, --hostname ECOPAGES_HOSTNAMEServer hostname
-b, --base-url ECOPAGES_BASE_URLPublic base URL
-d, --debugECOPAGES_LOGGER_DEBUGEnable debug logs
-r, --react-fast-refresh-Enable React Fast Refresh

Environment Variables

Ecopages listens to environment variables for configuration. When these are set, they often override defaults, but specific rules apply for precedence.

Canonical Base URL

Used for generating absolute URLs in production builds (meta tags, sitemaps, etc.).

  1. ConfigBuilder.setBaseUrl(): Highest priority. Set directly in eco.config.ts.
  2. ECOPAGES_BASE_URL: Environment variable override.
  3. Default: http://localhost:3000.

Server Hostname & Port

Used to determine where the server listens.

  1. serverOptions: Highest priority. Passed to the EcopagesApp constructor.
  2. Environment Variables: ECOPAGES_PORT and ECOPAGES_HOSTNAME.
  3. Defaults: localhost:3000.
VariableDescriptionDefault
ECOPAGES_BASE_URLThe canonical base URL of your site.http://localhost:3000
ECOPAGES_PORTThe port the server listens on.3000
ECOPAGES_HOSTNAMEThe hostname the server binds to.localhost
ECOPAGES_LOGGER_DEBUGEnables verbose debug logging.false

Example Usage

Show CLI help

bunx ecopages --help

Initialize a starter app

bunx ecopages init ecopages-app

Run development server

bunx ecopages dev

Build for production with a specific base URL

ECOPAGES_BASE_URL=https://my-site.com bunx ecopages build

Start the production server

NODE_ENV=production bunx ecopages start