compile command transforms your mini-program source into one or more target platform outputs.
mor compile reads your mor.config.ts file. CLI flags override the corresponding config file values when both are present.Source and target
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, alipayThe 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, webControls 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.
bundle, transformThe artifact type to produce. Each type uses a different entry config file.
Accepted values:
| Value | Entry file |
|---|---|
miniprogram | app.json |
plugin | plugin.json |
subpackage | subpackage.json |
component | component.json |
miniprogram, plugin, subpackage, componentPaths
Root directory of your source code.
Directory where compiled output is written. Defaults to
dist/<target> when not set (for example, dist/wechat).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
Sets the build mode, which affects defaults for caching, minification, and source maps. Mirrors webpack’s
mode option.Accepted values: production, development, noneShorthand for
--mode production. Automatically enables minimization.Enable watch mode. MorJS recompiles affected files when changes are detected.
Delete the output directory before each build.
Caching
Enable the build cache. Defaults to
true in development mode and false in production mode.Disable the build cache.
Source maps (devtool)
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.Disable source map generation entirely.
Minification
Enable output minification. Automatically enabled when
--production is set.Choose the JavaScript minimizer.Accepted values:
terser, esbuild, swcPass without a value to use the default minimizer.Disable JavaScript minification.
Choose the CSS minimizer.Accepted values:
esbuild, csso, cssnano, cleancss, parcelcssPass without a value to use the default minimizer (esbuild).Disable CSS minification.
Enable template (XML/WXML/AXML) minification using
html-terser.Disable template minification.
Runtime and dependencies
Process and cross-compile components inside
node_modules. Disabled by default. Enable this when using multi-platform component libraries.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
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 whencompose: true is set in your config, or when running mor compile in a project with compose configuration.
Specify which modules to include in the integration step. Accepts glob patterns.
Exclude modules from the integration step. Accepts glob patterns.
Set the initial state for module integration. Accepts values from
0 (initial) to 6 (composed).Set the final state for module integration. Accepts values from
0 (initial) to 6 (composed).Maximum number of modules to process in parallel during integration.
Merge all subpackage pages into the main package instead of keeping them as separate subpackages.
Usage examples
Multiple targets via config
To compile to several platforms in a single command, export an array frommor.config.ts:
mor.config.ts
Compiler options reference →
Full documentation for all compiler configuration fields available in
mor.config.ts.