Skip to content

Configuration

Alasdair Mercer edited this page Sep 27, 2017 · 4 revisions

Brander is entirely configuration based. It's designed so that there's minimal configuration required while remaining powerful and flexible. As Brander is intended to be used by anyone, not just developers, it aims to keep this configuration simple. Only a single configuration file is needed in the root of your project. By default, Brander looks for the following files in the base/working directory in the specified order:

  1. .branderrc (JSON)
  2. .branderrc.json (JSON)
  3. .branderrc.js (JavaScript)

Here's a small example of a configuration file:

TODO: Update example to included "docs" configuration

{
  "name": "my-brand",
  "title": "My Brand",
  "tasks": [
    {
      "task": "clean",
      "input": {
        "files": [
          "logo/**/*.ico",
          "logo/**/*.min.svg",
          "logo/**/*.png"
        ]
      },
      "options": {
        "groupBy": "<%= file.format %>"
      }
    },
    {
      "task": "convert",
      "input": {
        "files": "logo/**/*.svg"
      },
      "output": {
        "format": "png"
      },
      "options": {
        "sizes": [ 16, 32, 64, 128, 256, 512, 1024 ]
      }
    },
    {
      "task": "package",
      "input": {
        "files": "logo/**/*-256x256.png"
      },
      "output": {
        "files": "<%= file.base(true).replace('-256x256', '') %>.ico"
      },
      "options": {
        "groupBy": "<%= file.dir %>",
        "sizes": [ 16, 32, 48, 256 ]
      }
    },
    {
      "task": "optimize",
      "input": {
        "files": "logo/**/*.svg"
      }
    }
  ]
}

For more information and examples on configuring asset and documentation generation, see their respective pages.

We at !ninja use Brander to generate our own branding assets and docs. Take a look at our projects, in particularly the .branderrc.json file in our branding repository.

Schema

The following is the JSON Schema for the configuration file:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "title": { "type": "string" },
    "tasks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "task": { "type": "string" },
          "input": {
            "type": "object",
            "properties": {
              "dir": { "type": "string" },
              "files": {
                "anyOf": [
                  { "type": "string" },
                  {
                    "type": "array",
                    "items": { "type": "string" }
                  }
                ]
              },
              "format": { "type": "string" }
            },
            "required": [ "files" ]
          },
          "output": {
            "type": "object",
            "properties": {
              "dir": { "type": "string" },
              "files": { "type": "string" },
              "format": { "type": "string" }
            },
            "anyOf": [
              { "required": [ "files" ] },
              { "required": [ "format" ] }
            ]
          },
          "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*$"
                    }
                  ]
                }
              }
            }
          }
        },
        "required": [
          "input",
          "task"
        ]
      }
    },
    "docs": {
      "type": "object",
      "properties": {}
    },
    "options": {
      "type": "object",
      "properties": {
        "assets": {
          "type": "object",
          "properties": {
            "dir": {
              "type": "string",
              "default": "assets"
            }
          }
        },
        "docs": {
          "type": "object",
          "properties": {
            "dir": {
              "type": "string",
              "default": "docs"
            }
          }
        }
      }
    }
  }
}

Clone this wiki locally