-
Notifications
You must be signed in to change notification settings - Fork 17
How to config
See the main script file of your app. If you saw something like this ,
var app = lark({ directory : 'my_configs' });
Then your config files are under app_dir/my_configs
.
Note that in apps with some versions of lark, directory
contains app_dir
as well
By default, the directory is app_dir/config
Briefly speaking, you'll get app.config
(global) or this.config
(in middlewares) when your app runs, and each attribute of app.config
corresponds to a file in your config directory.
If the content of app_dir/config/whatever
is
module.exports = {
hello : "world",
foo : "bar",
};
Then the content of app.config.whatever
should be
{
hello : "world",
foo : "bar"
}
You can custom your own configs through this method. Both .js
and .json
are supported.
But remember, config directories are not supported yet.
Under the config directory you may notice that only env is a directory. Usually there are 2 files under env, production.js and development.js.
Each of the files defines some configs only for that running environment, with higher priority.
For example, you defined whatever
as above.You can override the config in development.js like:
module.exports.whatever = {
hello : "vi-ringbells",
foo : "barbar"
};
When running under development environment ( use lark -e development start
) you'll find now app.config.whatever.hello
is vi-ringbells
.
Refer merge for how it works.