LogoRevali

Construct Config

The configuration file for your construct

Now that we have created the entrypoint for our construct, we need a way to tell Revali where to find the entrypoint and how to generate the code. This is done by creating a construct.yaml file in the root of your project.

Create construct.yaml#

Create a new file in the root of your project called construct.yaml. This file will contain the configuration for your construct.

./construct.yaml
constructs:
    - name: my_construct
      path: my_construct_entrypoint.dart
      method: myConstructEntrypoint

Yaml Structure#

Required Properties#

The construct.yaml file contains a list of constructs that you want to generate. Each construct should have the following properties:

  • name: The name of the construct. This is used by Revali to identify the construct. If there other constructs that match the same name, Revali will use the name from the pubspec.yaml to further identify the construct.

    The `name` property should be unique across all constructs in your project.
    
- `path`: The path to the entrypoint file for the construct. This should be a relative path from the `lib` directory of your project.
```tree
.
├── lib
│   ├── my_construct_entrypoint.dart
│   └── ...
├── construct.yaml
└── pubspec.yaml
```
  • method: The name of the function in the entrypoint file that returns the Construct object.
lib/my_construct_entrypoint.dart
```dart
import 'package:revali_construct/revali_construct.dart';

// highlight-next-line
Construct myConstructEntrypoint([ConstructOptions? options]) {
    ...
}
```

Optional Properties#

is_build#

A boolean value that indicates whether the construct is generating the build code. The code generated by this construct will be placed within the .revali/build directory.

Build Construct

When is_build is set to true, you will need to return a BuildConstruct object instead of the general Construct object.

lib/my_construct_entrypoint.dart
import 'package:revali_construct/revali_construct.dart';

// highlight-next-line
BuildConstruct myConstructEntrypoint([ConstructOptions? options]) {
    ...
}

opt_in#

A boolean value that indicates whether the Construct is disabled by default and requires the user to opt-in to use it. This is useful when you have a Construct that is not commonly used, is experimental, or conflicting with other Constructs.

./construct.yaml
constructs:
    - name: my_construct
      ...
      # highlight-next-line
      opt_in: true