1 | # WARNING!
|
2 | > This documentation is not complete. It's in progress and it's a
|
3 | BETA version. Use the tool at your own risk.
|
4 |
|
5 | # @mhy/config
|
6 | This lib is a collection of all configuration and UI panels (ecosystem)
|
7 | `@mhy` uses.
|
8 |
|
9 | # Config
|
10 | Load configuration based on the current environment from folders
|
11 | (see repo) and/or from a project's `package.json` file.
|
12 | The final object structure is being represented in the
|
13 | directory/package.json structure. (see repo)
|
14 |
|
15 | Config options are being separated into environments. By default `@mhy`
|
16 | uses **root** (always used), **development** and **production**.
|
17 |
|
18 | # Examples
|
19 | ```
|
20 | // Dir structure
|
21 | foo
|
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 |
|
31 | API
|
32 | ```
|
33 | import { load } from '@mhy/config'
|
34 |
|
35 | load('foo')
|
36 | ```
|
37 |
|
38 | CLI
|
39 | ```
|
40 | mhy config foo
|
41 | ```
|
42 |
|
43 | Output
|
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
|
53 | being loaded.
|
54 |
|
55 | Defining env
|
56 | ```
|
57 | // *nix
|
58 | NODE_ENV=production mhy config foo
|
59 |
|
60 | // Windows
|
61 | set NODE_ENV=production&& mhy config foo // not a typo, no space needed there!
|
62 | ```
|
63 |
|
64 | ## CLI
|
65 | It'll return the configuration object being used from `@mhy/config`.
|
66 |
|
67 | ```
|
68 | // Print out config
|
69 | mhy config webpack
|
70 |
|
71 | // Print out config in different format
|
72 | mhy config babel -f json
|
73 | mhy config babel --format=json
|
74 |
|
75 | // Print out config in different format and save into a file
|
76 | mhy config babel -f json >> .babelrc
|
77 | ```
|
78 |
|
79 | ## Custom overrides
|
80 |
|
81 | ### `using files/folders`
|
82 | Structure
|
83 | ```
|
84 | webpack
|
85 | development
|
86 | devServer.js
|
87 | ```
|
88 |
|
89 | devServer.js file
|
90 | ```
|
91 | module.exports = (defaults) => ({
|
92 | ...defaults,
|
93 | host: 'my-host.com'
|
94 | })
|
95 | ```
|
96 |
|
97 | ### Using `package.json`
|
98 | package.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
|
116 | 1. Load **root** config from package dir/files.
|
117 | 2. Load **env** config from package dir/files.
|
118 | 3. Load **root** config from project `package.json`.
|
119 | 4. Load **env** config from project `package.json`.
|
120 |
|
121 | # UI
|
122 | UIs are basically built-in ecosystem tasks. You can run all of them
|
123 | at once or separately.
|
124 | ```
|
125 | // Run ecosystem (ui) (default)
|
126 | mhy
|
127 | mhy ui
|
128 |
|
129 | // Run specific ui process only
|
130 | mhy webpack-dev-server
|
131 | mhy run webpack-dev-server
|
132 |
|
133 | // Run specific process only with specific task
|
134 | mhy jest watch
|
135 | mhy 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
|
145 | By default the following panels are enabled when you simply run `mhy`:
|
146 | - `jest`
|
147 | - `storybook-start`
|
148 | - `webpack-dev-server`
|
149 | - `tsc`
|
150 |
|
151 | Disabled by default:
|
152 | - `prettier` `webpack-dev-server` already handles it, but it can be
|
153 | useful to run it before pushing commits and such.
|
154 |
|
155 | However, you can can explicitly enable/disable panels in `package.json`
|
156 | per environment, or explicitly tell which panels to run in CLI.
|
157 |
|
158 | ```
|
159 | mhy 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 |