Skip to main content
The compile command transforms your mini-program source into one or more target platform outputs.
mor compile [options]
mor compile reads your mor.config.ts file. CLI flags override the corresponding config file values when both are present.

Source and target

--source-type
string
The DSL used in your source code. MorJS auto-detects this from .wxml or .axml file extensions. Set explicitly if both file types exist in the same directory.Accepted values: wechat, alipay
-t, --target
string
The platform to compile to. Each target has its own default output directory (for example, dist/wechat).Accepted values: wechat, alipay, baidu, bytedance, qq, kuaishou, taobao, dingding, web
--compile-mode
string
default:"bundle"
Controls how modules and dependencies are processed.
  • bundle — Full webpack bundling. Resolves and inlines npm packages. Recommended for production.
  • transform — Source-only conversion. Does not process npm dependencies. Useful for library authors.
Accepted values: bundle, transform
--compile-type
string
default:"miniprogram"
The artifact type to produce. Each type uses a different entry config file.
ValueEntry file
miniprogramapp.json
pluginplugin.json
subpackagesubpackage.json
componentcomponent.json
Accepted values: miniprogram, plugin, subpackage, component

Paths

-s, --src-path
string
default:"./src"
Root directory of your source code.
-o, --output-path
string
Directory where compiled output is written. Defaults to dist/<target> when not set (for example, dist/wechat).
--ignore
string
A file or directory path to exclude from compilation. Output directories are added to the ignore list automatically. Pass the flag multiple times to ignore multiple paths.

Build mode

--mode
string
default:"development"
Sets the build mode, which affects defaults for caching, minification, and source maps. Mirrors webpack’s mode option.Accepted values: production, development, none
--production
boolean
Shorthand for --mode production. Automatically enables minimization.
-w, --watch
boolean
default:"false"
Enable watch mode. MorJS recompiles affected files when changes are detected.
--auto-clean
boolean
default:"false"
Delete the output directory before each build.

Caching

--cache
boolean
Enable the build cache. Defaults to true in development mode and false in production mode.
--no-cache
boolean
Disable the build cache.

Source maps (devtool)

-d, --devtool
string
Control source map generation. Accepts any webpack devtool value, for example source-map, eval-cheap-source-map, or inline-source-map.Pass the flag without a value to use webpack’s default for the current mode.
--no-devtool
boolean
Disable source map generation entirely.

Minification

--minimize
boolean
Enable output minification. Automatically enabled when --production is set.
--js-minimizer
string
default:"true"
Choose the JavaScript minimizer.Accepted values: terser, esbuild, swcPass without a value to use the default minimizer.
--no-js-minimizer
boolean
Disable JavaScript minification.
--css-minimizer
string
default:"esbuild"
Choose the CSS minimizer.Accepted values: esbuild, csso, cssnano, cleancss, parcelcssPass without a value to use the default minimizer (esbuild).
--no-css-minimizer
boolean
Disable CSS minification.
--xml-minimizer
boolean
Enable template (XML/WXML/AXML) minification using html-terser.
--no-xml-minimizer
boolean
Disable template minification.

Runtime and dependencies

--process-node-modules
boolean
Process and cross-compile components inside node_modules. Disabled by default. Enable this when using multi-platform component libraries.
--global-object
string
Override the global object name used by the target platform (for example, wx for WeChat, my for Alipay). Each target has a sensible default; you rarely need to set this manually.

Bundle analysis

--analyze
boolean
Open a bundle analysis report using webpack-bundle-analyzer. The server starts at http://127.0.0.1:8888 by default.

Compose integration flags

The following flags are available when compose: true is set in your config, or when running mor compile in a project with compose configuration.
--with-modules
string
Specify which modules to include in the integration step. Accepts glob patterns.
--without-modules
string
Exclude modules from the integration step. Accepts glob patterns.
--from-state
number
Set the initial state for module integration. Accepts values from 0 (initial) to 6 (composed).
--to-state
number
Set the final state for module integration. Accepts values from 0 (initial) to 6 (composed).
--concurrency
number
Maximum number of modules to process in parallel during integration.
--combine-modules
boolean
Merge all subpackage pages into the main package instead of keeping them as separate subpackages.

Usage examples

mor compile --target wechat

Multiple targets via config

To compile to several platforms in a single command, export an array from mor.config.ts:
mor.config.ts
import { defineConfig } from '@morjs/cli'

export default defineConfig([
  {
    name: 'wechat',
    sourceType: 'wechat',
    target: 'wechat',
    compileMode: 'bundle'
  },
  {
    name: 'alipay',
    sourceType: 'wechat',
    target: 'alipay',
    compileMode: 'bundle'
  }
])
Then run:
mor compile

Compiler options reference →

Full documentation for all compiler configuration fields available in mor.config.ts.

Build docs developers (and LLMs) love