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 |
|
10 | This helper encapsulates the logic for loading a mako build configuration file, allowing easier
|
11 | use amongst different tools.
|
12 |
|
13 | ## Usage
|
14 |
|
15 | This module is a simple function loads and normalizes mako configuration files:
|
16 |
|
17 | ```js
|
18 | var load = require('mako-config');
|
19 |
|
20 | load('/path/to/file.json').then(function (config) {
|
21 | // config.entries
|
22 | // config.plugins
|
23 | });
|
24 | ```
|
25 |
|
26 | ## Configuration File Structure
|
27 |
|
28 | ### entries
|
29 |
|
30 | This will be an array of glob patterns that will be resolved to form a single list of entry files.
|
31 | The 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 |
|
45 | This will be an array of plugins to load, they can either be installed modules or point to local
|
46 | modules of your own:
|
47 |
|
48 | ```json
|
49 | {
|
50 | "plugins": [
|
51 | "mako-browser",
|
52 | "./local-plugin.js"
|
53 | ]
|
54 | }
|
55 | ```
|
56 |
|
57 | By 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 |
|
71 | This function accepts `file` as an absolute path to the configuration file. The `overrides`
|
72 | is a list of entries that will override the ones specified in the config file.
|
73 |
|
74 | It 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 |
|
81 | The same arguments are accepted, and the same result is returned synchronously.
|