UNPKG

3.37 kBMarkdownView Raw
1# WARNING!
2> This documentation is not complete. It's in progress and it's a
3BETA version. Use the tool at your own risk.
4
5# @mhy/config
6This lib is a collection of all configuration and UI panels (ecosystem)
7 `@mhy` uses.
8
9# Config
10Load configuration based on the current environment from folders
11(see repo) and/or from a project's `package.json` file.
12The final object structure is being represented in the
13directory/package.json structure. (see repo)
14
15Config options are being separated into environments. By default `@mhy`
16uses **root** (always used), **development** and **production**.
17
18# Examples
19```
20// Dir structure
21foo
22 index.js
23 development
24 bar.js => exports 1
25 production
26 baz.js => exports 2
27 root
28 fip.js => exports 3
29```
30
31API
32```
33import { load } from '@mhy/config'
34
35load('foo')
36```
37
38CLI
39```
40mhy config foo
41```
42
43Output
44```
45{
46 bar: 1,
47 fip: 3
48}
49*/
50```
51
52> `baz` is missing because `development` env is default thus it's not
53being loaded.
54
55Defining env
56```
57// *nix
58NODE_ENV=production mhy config foo
59
60// Windows
61set NODE_ENV=production&& mhy config foo // not a typo, no space needed there!
62```
63
64## CLI
65It'll return the configuration object being used from `@mhy/config`.
66
67```
68// Print out config
69mhy config webpack
70
71// Print out config in different format
72mhy config babel -f json
73mhy config babel --format=json
74
75// Print out config in different format and save into a file
76mhy config babel -f json >> .babelrc
77```
78
79## Custom overrides
80
81### `using files/folders`
82Structure
83```
84webpack
85 development
86 devServer.js
87```
88
89devServer.js file
90```
91module.exports = (defaults) => ({
92 ...defaults,
93 host: 'my-host.com'
94})
95```
96
97### Using `package.json`
98package.json file
99```
100{
101 ...
102 "mhy" {
103 "webpack": {
104 "development": {
105 "devServer": {
106 "host": "my-host.com"
107 }
108 }
109 }
110 }
111 ...
112}
113```
114
115### Flow
1161. Load **root** config from package dir/files.
1172. Load **env** config from package dir/files.
1183. Load **root** config from project `package.json`.
1194. Load **env** config from project `package.json`.
120
121# UI
122UIs are basically built-in ecosystem tasks. You can run all of them
123at once or separately.
124```
125// Run ecosystem (ui) (default)
126mhy
127mhy ui
128
129// Run specific ui process only
130mhy webpack-dev-server
131mhy run webpack-dev-server
132
133// Run specific process only with specific task
134mhy jest watch
135mhy run jest watch
136```
137
138## Navigation with-in UI
139- `Tab` change active panel
140- `Left/Right arrow` select action
141- `Enter` run selected action
142- `Up/Down arrow` scroll up/down in the selected panel
143
144## UI Panels
145By default the following panels are enabled when you simply run `mhy`:
146- `jest`
147- `storybook-start`
148- `webpack-dev-server`
149- `tsc`
150
151Disabled by default:
152- `prettier` `webpack-dev-server` already handles it, but it can be
153useful to run it before pushing commits and such.
154
155However, you can can explicitly enable/disable panels in `package.json`
156per environment, or explicitly tell which panels to run in CLI.
157
158```
159mhy ui prettier storybook-start
160```
161
162### Enabling panels
163```
164"mhy": {
165 "ui": {
166 "root": {
167 "enabled": [
168 "prettier"
169 ]
170 }
171 }
172}
173```
174
175### Disabling panels
176```
177"mhy": {
178 "ui": {
179 "root": {
180 "disabled": [
181 "tsc"
182 ]
183 }
184 }
185}
186```
\No newline at end of file