rofrischmann/elodin

View on GitHub
website/pages/docs/setup/configuration.mdx

Summary

Maintainability
Test Coverage
import DocLayout from '../../../components/DocLayout.js'

export default DocLayout

# Configuration

We already learned that Elodin requires a generator and a list of sources to run.<br />
Apart from that, we can pass a bunch of other configurations.

| Configuration | Value          | Default | Description                                                                                                      |
| ------------- | -------------- | ------- | ---------------------------------------------------------------------------------------------------------------- |
| generator     | Generator      |         | The target generator that is used to compile all elodin files to a desired target format.                        |
| sources       | Array<Path\>   |         | List of source folders which contain elodin files that should be compiled.                                       |
| plugins       | Array<Plugin\> | _[]_    | List of plugins to be applied before compilation                                                                 |
| errors        | `throw`, `log` | _throw_ | Whether compilation errors throw or just log.<br />**It is recommend to throw in order to ensure valid output.** |

## Example

> **Note**: We're using ES5 here since it won't pre-compile configuration files by default. If you want to write modern ES2015+, you'll have to transpile those with e.g. Babel first.

```javascript name=elodin.config.js copy
var { createGenerator } = require('@elodin/generator-javascript-css')
var replaceVariable = require('@elodin/plugin-replace-variabe')

module.exports = {
  sources: ['src', 'components'],
  errors: 'log',
  plugins: [
    replaceVariable({
      variables: {
        primaryColor: 'blue',
        secondaryColor: 'red',
        baseFontSize: 16,
        gridStep: 8,
      },
    }),
  ],
  generator: createGenerator({
    devMode: true,
  }),
}
```