UNPKG

2.14 kBMarkdownView Raw
1# mako-config
2
3> A helper for loading mako build config from a file.
4
5[![npm version](https://img.shields.io/npm/v/mako-config.svg)](https://www.npmjs.com/package/mako-config)
6[![npm dependencies](https://img.shields.io/david/makojs/config.svg)](https://david-dm.org/makojs/config)
7[![npm dev dependencies](https://img.shields.io/david/dev/makojs/config.svg)](https://david-dm.org/makojs/config#info=devDependencies)
8[![build status](https://img.shields.io/travis/makojs/config.svg)](https://travis-ci.org/makojs/config)
9
10This helper encapsulates the logic for loading a mako build configuration file, allowing easier
11use amongst different tools.
12
13## Usage
14
15This module is a simple function loads and normalizes mako configuration files:
16
17```js
18var load = require('mako-config');
19
20load('/path/to/file.json').then(function (config) {
21 // config.entries
22 // config.plugins
23});
24```
25
26## Configuration File Structure
27
28### entries
29
30This will be an array of glob patterns that will be resolved to form a single list of entry files.
31The patterns will all be resolved relative to the config file's location.
32
33```json
34{
35 "entries": [
36 "index.{js,css}",
37 "pages/**/index.{js,css}",
38 "public/**"
39 ]
40}
41```
42
43### plugins
44
45This will be an array of plugins to load, they can either be installed modules or point to local
46modules of your own:
47
48```json
49{
50 "plugins": [
51 "mako-browser",
52 "./local-plugin.js"
53 ]
54}
55```
56
57By default, no arguments will be passed during initialization. To change this, use an array:
58
59```json
60{
61 "plugins": [
62 [ "mako-browser", { "output": "dist" } ]
63 ]
64}
65```
66
67## API
68
69### load(file, [overrides])
70
71This function accepts `file` as an absolute path to the configuration file. The `overrides`
72is a list of entries that will override the ones specified in the config file.
73
74It returns a promise that resolves with an object. It will contain the following keys:
75
76 - `entries`: an array of absolute file paths to all the matched entry files
77 - `plugins`: an array of the initialized plugin functions
78
79### load.sync(file, [overrides])
80
81The same arguments are accepted, and the same result is returned synchronously.