-
-
Notifications
You must be signed in to change notification settings - Fork 0
Assets
Brander's ability to generate assets is built on a task-based system which can be configured in the .branderrc file. These all follow the same general schema within the configuration:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"input": {
"type": "object",
"properties": {
"dir": { "type": "string" },
"files": {
"anyOf": [
{ "type": "string" },
{
"type": "array",
"items": { "type": "string" }
}
]
},
"format": { "type": "string" }
},
"required": [ "files" ]
},
"options": {
"type": "object",
"properties": {
"groupBy": { "type": "string" },
"sizes": {
"type": "array",
"items": {
"anyOf": [
{
"type": "number",
"exclusiveMinimum": 0
},
{
"type": "string",
"pattern": "^\\s*\\d+\\s*([xX]\\s*\\d+)?\\s*$"
}
]
}
}
}
},
"output": {
"type": "object",
"properties": {
"dir": { "type": "string" },
"files": { "type": "string" },
"format": { "type": "string" }
},
"anyOf": [
{ "required": [ "files" ] },
{ "required": [ "format" ] }
]
},
"task": { "type": "string" }
},
"required": [
"input",
"task"
]
}The tasks are executed in the order in which they are declared within the configuration file. A task can only be executed for a single input and output format combination, however, you can simply declare multiple tasks for different formats. For example, the following configuration is invalid as the "input.files" configuration contains files of mixed formats:
{
"tasks": [
{
"task": "clean",
"input": {
"files": [
"logo/**/*.png",
"logo/**/*.min.svg"
]
}
}
]
}But this could easily by fixed by splitting that task up for each unique format:
{
"tasks": [
{
"task": "clean",
"input": {
"files": "logo/**/*.png"
}
},
{
"task": "clean",
"input": {
"files": "logo/**/*.min.svg"
}
}
]
}Tasks are split into three types: clean, convert, and optimize. The "task" configuration is used to identify one of these and the rest of the information is only needed to provide the specifics for that task. There are some variations with relating to the configuration between these types that will be explained further in the sections below.
TODO: Cover evaluated values (file.dir, file.name, option.groupBy)
clean tasks simply force deletes all of the input files found. These are generally declared before or after all other tasks, however, they can be declared at any point.
The "output" configuration is ignored entirely by this task type as there is no output generated as a result of its execution.
Removing all PNG and optimized SVG files before re-generating them:
{
"tasks": [
{
"task": "clean",
"input": {
"files": "logo/**/*.png"
}
},
{
"task": "clean",
"input": {
"files": "logo/**/*.min.svg"
}
}
]
}This is good practice to ensure a clean slate each time Brander is executed.
TODO: Describe convert tasks
TODO: Describe convert tasks