Skip to main content

Targets

A target is an identifier that pairs a project to one of its tasks, in the format of project_name_or_alias:task_name.

Targets are used by terminal commands...

$ moon run designSystem:build

And configurations for declaring cross-project or cross-task dependencies.

tasks:
build:
command: 'webpack'
deps:
- 'designSystem:build'

Project scopes

While a target typically pairs project and task names, we also support advanced targets through a concept known as project scopes. Scopes allow us to easily define targets with external or many sources, but are not available in all contexts.

All projects

Only available on the command line when running targets.

For situations where you want to run a specific target in all projects, for example linting, you can utilize the all projects scope by omitting the project from the target: :lint.

# Run `lint` in project `app`
$ moon run app:lint

# Run `lint` in all projects
$ moon run :lint

Dependencies ^

Only available when configuring a task.

When you want to include a reference for each project in your dependsOn list, you can utilize the ^ scope. This will be expanded to all depended on projects. If you do not want all projects, then you'll need to explicitly define them.

moon.yml
dependsOn:
- 'apiClients'
- 'designSystem'

# Configured as
tasks:
build:
command: 'webpack'
deps:
- '^:build'

# Resolves to
tasks:
build:
command: 'webpack'
deps:
- 'apiClients:build'
- 'designSystem:build'

Self ~

Only available when configuring a task.

When referring to another task within the current project, you can utilize the ~ scope, which will be expanded to the current project's name. This is useful for situations where the name is unknown, for example, when configuring .moon/project.yml. Or if you just want a shortcut!

.moon/project.yml
# Configured as
tasks:
lint:
command: 'eslint'
deps:
- '~:typecheck'
typecheck:
command: 'tsc'

# Resolves to (assuming project is "foo")
tasks:
lint:
command: 'eslint'
deps:
- 'foo:typecheck'
typecheck:
command: 'tsc'