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.
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 thenamefrom thepubspec.yamlto further identify the construct.The `name` property should be unique across all constructs in your project.
```tree
.
├── lib
│ ├── my_construct_entrypoint.dart
│ └── ...
├── construct.yaml
└── pubspec.yaml
```
-
method: The name of the function in the entrypoint file that returns theConstructobject.
```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.
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.
constructs:
- name: my_construct
...
# highlight-next-line
opt_in: true