mor.config.ts config object (or within each array entry for multi-config exports).
Source and target
The DSL used in your source files. MorJS auto-detects this by looking for
.wxml (WeChat) or .axml (Alipay) template files. Only set this explicitly when both types of files exist in the same directory.Accepted values: wechat, alipayThe platform target for the compiled output. Defaults to the first registered target. Each target has a default output path under
dist/.Accepted values: wechat, alipay, baidu, bytedance, qq, kuaishou, taobao, dingding, webCompilation strategy.
bundle— Full webpack bundling with npm package resolution. Produces a self-contained output with nonode_modules.transform— Source-only conversion. Dependencies are not bundled; useful for component library authors.
bundle, transformThe type of artifact to produce. Determines the root 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 files.
Additional source root directories. Useful when source files are spread across multiple directories.
Directory where compiled output is written. Defaults to
dist/<target> when not set.Files and directories to exclude from compilation. All
outputPath values are added to this list automatically.Build mode
Build mode. Mirrors webpack’s
mode option. Affects tree-shaking, optimization, and source map defaults.Accepted values: production, development, noneEnable file watch mode. MorJS rebuilds affected files when changes are detected.
Delete the output directory before each build.
Enable the webpack filesystem cache. Defaults to
true in development mode and false in production mode.Minification
Enable output minification. Automatically set to
true when mode is production.JavaScript minimizer to use when
minimize is enabled.Accepted values: terser, esbuild, swc, true (use default), false (disable JS minification)Options passed directly to the chosen JS minimizer. The shape depends on which minimizer is selected.
CSS minimizer to use when
minimize is enabled.Accepted values: esbuild, csso, cssnano, cleancss, parcelcss, false (disable CSS minification)Options passed directly to the chosen CSS minimizer.
Enable template (WXML/AXML) minification using
html-terser.Options passed to the XML minimizer.
Source maps
Source map generation strategy. Accepts any webpack devtool string value (for example,
source-map, eval-cheap-source-map), or false to disable source maps entirely.Aliases and defines
Module path aliases. These are passed to webpack’s
resolve.alias option.Global constants to inject into source code at compile time. Only effective in
bundle mode.File copying
Files or directories to copy from source to output. Entries can be plain strings (file path relative to Object fields:
srcPath) or objects:from(string) — Source path relative tosrcPathorsrcPaths.to(string) — Destination path relative tooutputPath.context(string) — Optional base directory override.force(boolean) — Overwrite existing files.toType(string) —'file'or'dir'.priority(number) — Copy order priority.globOptions(object) — Glob matching options.filter(function) — Custom filter(filePath: string) => boolean.
Node modules processing
Whether to cross-compile components inside
node_modules. By default, MorJS chooses automatically based on the target platform.Pass true to process all node_modules, or an object for fine-grained control:Override the global object name for the target platform (
wx for WeChat, my for Alipay, etc.). Each target sets a sensible default; rarely needs to be overridden.Runtime injection
Automatically inject MorJS runtime wrappers at compile time. When
true, all injection types are enabled based on platform defaults. When false, no runtime injection occurs.Use an object for granular control:api accepted values: enhanced (replace global object + inject mor API shim), lite (simple global rename), minimal (replace function calls only), false (disable).TypeScript compiler options
TypeScript compilation settings. These mirror standard
tsconfig.json options.Conditional compilation
Configure compile-time conditional code inclusion.
Custom entries
Override or extend the entry configuration. Useful when your entry config file is in a non-standard location, or when you need to compile extra pages or components that have no reference in
app.json.Phantom dependency detection
Detect imports of packages that are not declared in
package.json. Pass true to enable with default settings, or an object for configuration:mode: 'warn'— Log a warning for each phantom dependency.mode: 'error'— Throw an error and fail the build.
Module sharing (subpackage federation)
Declare
node_modules packages to expose for consumption by other configs in a multi-repo subpackage setup.Declare
node_modules packages to consume from a shared host instead of bundling locally.App JSON script generation
Generate a
mor.p.js script file used to update app.json content during integration. Disable this if you manage integration separately.Bundle analysis
Enable bundle analysis with
webpack-bundle-analyzer. Pass true to use defaults, or an object to configure:Experimental features
Opt-in experimental features. These may change between minor versions.
webpack passthrough
Passed directly to webpack’s
externals configuration. Use to exclude specific packages from the bundle.Sets the default external type. Defaults vary by target; for web targets you may need to set this to
'window'.