@weapp-stylex/compiler

Shared StyleX compiler for WeChat, Alipay, Douyin and H5: JavaScript, TypeScript, Vue SFC and atomic styles
1,139 2
Install
npm install @weapp-stylex/compiler
Latest Version:0.3.1
License:MIT
Last Updated:Oct 18, 2026
Links: GitHub  ·  npm
Maintainer: icebreaker

@weapp-stylex/compiler

weapp-stylex 的共享构建核心:使用官方 StyleX Babel 插件转换模块,维护模块规则和主题依赖,预处理 Vue SFC,并规划跨平台小程序样式与 H5 CSS 产物。提供 ESM 和 CommonJS 入口。

应用项目优先使用 @weapp-stylex/weapp-vite、@weapp-stylex/taro 或 @weapp-stylex/uni-app;本包供构建适配器使用。

pnpm add -D @weapp-stylex/compiler
import { createVitePlugins, StylexSession } from '@weapp-stylex/compiler'

const session = new StylexSession()
const plugins = createVitePlugins(session)

支持普通共享样式模块、别名、workspace 源码及官方 tokens.stylex.ts 主题约定。保持 StyleX 单位语义,关闭 CSS Layers、specificity polyfill 和 runtime CSS 注入。

要求 Node.js ^22.22.1 || >=24.11.0。API、生命周期和适配器契约见 weapp-stylex。

MIT License。

构建使用 tsdown,保留 ESM/CJS 与对应声明;官方 runtime、Babel 及可选 SWC addon 保持 external,原生 addon 按需加载。

Platforms

StylexSession({ target }) accepts weapp, alipay, tt or web and defaults to weapp. Mini-program targets map default variables to page; Web retains :root. MiniProgramStyleEmitter plans platform template/style companions, while WxssEmitter preserves the existing WeChat API. Web helpers provide host-owned CSS delivery and static rpx conversion. See the compiler API for the host integration contract.

Related Packages

@weapp-stylex/uni-app

StyleX Vite plugin for uni-app Vue 3 targeting WeChat, Alipay, Douyin and H5

963 2
@weapp-stylex/weapp-vite

StyleX compiler integration for native and Wevu mini-programs and the weapp-vite...

959 2
@weapp-stylex/taro

StyleX plugin for Taro React and Vue 3 targeting WeChat, Alipay, Douyin and H5 w...

1,026 2
weapp-stylex

StyleX runtime and build adapters for WeChat, Alipay, Douyin and H5: native, Wev...

905 2
@stylexswc/unplugin

Universal StyleX plugin for Vite, webpack, Rspack, Rollup, esbuild, Farm, Rsbuil...

778,082 112

Version History

Version Released License
0.3.1 MIT
0.3.0 MIT
0.2.0 MIT
0.1.1 MIT
0.1.0 MIT
Pre-releases (1)
Version Released License
0.0.0-stage