Skip to main content
MorJS reads configuration from 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

import { defineConfig } from '@morjs/cli'

export default defineConfig({
  name: 'my-app',
  sourceType: 'wechat',
  target: 'wechat',
  compileMode: 'bundle'
})

Supported config file names

MorJS looks for these files in your project root, in order:
  • mor.config.ts
  • mor.config.mjs
  • mor.config.js
  • mor.config.json
  • mor.config.jsonc
  • mor.config.json5
You can also add a mor field to your package.json:
package.json
{
  "name": "my-app",
  "mor": {
    "sourceType": "wechat",
    "target": "wechat"
  }
}

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):
mor compile --name wechat
mor compile --name alipay
The name field must be unique across configs. Use descriptive names that match your target platform or build variant.

Top-level fields

name
string
A unique identifier for this config entry. Required when exporting an array of configs. Used to filter configs via the --name CLI flag.
sourceType
string
default:"wechat"
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, alipay
target
string
The 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, web
compileMode
string
default:"bundle"
How modules and dependencies are processed. bundle resolves and inlines npm packages. transform converts source files only without processing dependencies.Accepted values: bundle, transform
compileType
string
default:"miniprogram"
The artifact type. Determines which entry file is used.Accepted values: miniprogram, plugin, subpackage, component
srcPath
string
default:"./src"
Root directory of your source code.
outputPath
string
Output directory. Defaults to dist/<target> if not set.
mode
string
default:"development"
Build mode. Mirrors webpack’s mode option. Affects defaults for caching, minification, and source maps.Accepted values: production, development, none
plugins
array
List of MorJS plugins to apply. Each entry can be a plugin class instance, a package name string, or a [name, options] tuple.
plugins: [
  'my-plugin-package',
  ['another-plugin', { option: true }],
  new MyPlugin()
]
watch
boolean
default:"false"
Enable file watch mode.
autoClean
boolean
default:"false"
Delete the output directory before each build.
cache
boolean
Enable build caching. Defaults to true in development mode and false in production mode.
ignore
string[]
default:"[]"
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 when mode is development
  • .env.production — loaded when mode is production

Full config type

The UserConfig type exported from @morjs/cli combines all config areas:
import type { UserConfig } from '@morjs/cli'
It includes fields from:
  • 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.

Build docs developers (and LLMs) love