Ana içeriğe atla

Code Generation

Analog supports automated code generation using Nx Generators and Angular Schematics.

Generators

The Analog plugin for Nx provides a series of generators that help automate some of the frequent tasks inside an Nx workspace, like generating an application or page. To use these generators, the Nx Console extension can be installed or they can be invoked manually using the Nx CLI:

Generating an application

To generate a new Analog application within an Nx workspace, use the application generator:

npx nx generate @analogjs/platform:app my-app

Generating pages

npx nx generate @analogjs/platform:page --pathname=index --project=analog-app

it also works with the Analog specific filenames, Note: this names needs to be surrounded by single quotes ex:

npx nx generate @analogjs/platform:page --pathname='(blog)' --project=analog-app

The schematic as well accepts subfolders to structure our project properly.

npx nx generate @analogjs/platform:page --pathname='products/[products]' --project=analog-app