Overview
Settingtarget: 'web' compiles your Alipay or WeChat mini-program source into a standard web application. The output is a webpack bundle with HTML entry points — one route per mini-program page.
The web compiler is built on top of the Alipay compiler plugin and re-uses its template processing logic, so Alipay DSL (.axml / .acss) is natively supported. WeChat DSL is also supported through cross-platform transformation.
Minimal configuration
mor.config.ts
dist/web by default.
Web-specific config (web field)
All web-specific options live under the web key:
mor.config.ts
Pages as web routes
Each entry inapp.json’s pages array becomes a separate webpack entry point and an HTML file in the output. The routing is hash-based by default.
For example, with this app.json:
pages/index/index.htmlpages/detail/index.html
my.navigateTo, etc.) is handled by @morjs/runtime-web’s router.
Runtime web package
The web target depends on@morjs/runtime-web for:
- Mini-program API polyfills (
my.*/wx.*→ browser equivalents) - Built-in component implementations (
view,text,image,scroll-view, etc.) - Page/App lifecycle management in the browser
- Router bridging hash URLs to mini-program navigation
The web compiler locates
@morjs/runtime-web automatically. Ensure it is installed in the same node_modules tree as @morjs/cli.globalObject restriction
Development server
The web target supports a built-in dev server throughweb.devServer (webpack-dev-server options):
Known differences and limitations
No native mini-program APIs
Some platform-specific APIs (payments, biometrics, hardware sensors) have no browser equivalent and must be stubbed or removed.
Template compatibility
Complex SJS/WXS scripts and some template directives may require manual adjustments. The compiler handles common patterns automatically.
CSS units
rpx units are converted to rem by default (controlled by needRpx and rpxRootValue). Use usePx to convert to px instead.tabBar
The tabBar is rendered via the web runtime. Use
appConfig.customTabBarKey to control the active tab via URL query parameter.