mor.config.ts (or .js, .mjs, .json, .jsonc, .json5) in your project root. Use defineConfig from @morjs/cli to get full TypeScript type checking.
File format
Supported config file names
MorJS looks for these files in your project root, in order:mor.config.tsmor.config.mjsmor.config.jsmor.config.jsonmor.config.jsoncmor.config.json5
mor field to your package.json:
package.json
Multiple configs and the name field
When you export an array of configs, each config is identified by its name field. You can run a specific named config using the --name flag (or --config alias):
Top-level fields
A unique identifier for this config entry. Required when exporting an array of configs. Used to filter configs via the
--name CLI flag.The DSL your source code uses. MorJS auto-detects this from
.wxml or .axml file extensions in most cases. Set explicitly when both file types coexist in the same directory.Accepted values: wechat, alipayThe platform to compile to. Defaults to the first available target. Each target has a default output directory under
dist/.Accepted values: wechat, alipay, baidu, bytedance, qq, kuaishou, taobao, dingding, webHow modules and dependencies are processed.
bundle resolves and inlines npm packages. transform converts source files only without processing dependencies.Accepted values: bundle, transformThe artifact type. Determines which entry file is used.Accepted values:
miniprogram, plugin, subpackage, componentRoot directory of your source code.
Output directory. Defaults to
dist/<target> if not set.Build mode. Mirrors webpack’s
mode option. Affects defaults for caching, minification, and source maps.Accepted values: production, development, noneList of MorJS plugins to apply. Each entry can be a plugin class instance, a package name string, or a
[name, options] tuple.Enable file watch mode.
Delete the output directory before each build.
Enable build caching. Defaults to
true in development mode and false in production mode.Paths to exclude from compilation. Output directories are added automatically.
Environment variables
MorJS loads.env files automatically. You can use different files per environment:
.env— loaded in all cases.env.local— loaded in all cases, gitignored.env.development— loaded whenmodeisdevelopment.env.production— loaded whenmodeisproduction
Full config type
TheUserConfig type exported from @morjs/cli combines all config areas:
- Core takin fields (
name,plugins, etc.) - Compiler options (
sourceType,target,compileMode, etc.) - Compose options (
compose,host,modules, etc.) - Web-specific options (
web.*) - webpack passthrough options (
externals, etc.)
Compiler options →
All fields for controlling how source is compiled: minification, aliases, defines, and more.
Web options →
Web-specific configuration for rpx conversion, routing, dev server, and HTML output.