#style-sheet #css #compiler #isolation #minify #glass-easel #rpx

bin+lib glass-easel-stylesheet-compiler

The stylesheet compiler of the glass-easel project

18 releases (9 breaking)

new 0.10.3 Oct 17, 2024
0.9.0 Aug 7, 2024
0.8.2 Jul 24, 2024
0.3.1 Mar 1, 2024
0.1.1 Feb 3, 2023

#298 in WebAssembly

Download history 47/week @ 2024-07-01 120/week @ 2024-07-08 246/week @ 2024-07-22 14/week @ 2024-07-29 113/week @ 2024-08-05 4/week @ 2024-08-12 266/week @ 2024-09-09 201/week @ 2024-09-16 21/week @ 2024-09-23 55/week @ 2024-09-30 1/week @ 2024-10-07 133/week @ 2024-10-14

221 downloads per month

MIT license

65KB
1.5K SLoC

glass-easel-stylesheet-compiler

The stylesheet compiler for the glass-easel project.

This tool can help:

  • convert rpx to vw ;
  • work with style isolation options through class-prefixes;
  • minify the output CSS.

Refer to the glass-easel project for further details.

Build

rust toolchain and wasm-pack should be globally installed.

Build WebAssembly binary:

wasm-pack build glass-easel-stylesheet-compiler --target nodejs --out-dir pkg-nodejs

Build binary:

cargo build --release

JavaScript Interface

This tool can be used in webpack, i.e. glass-easel-miniprogram-webpack-plugin .

However, if you want to call it directly, see the example below.

const { StyleSheetTransformer } = require('glass-easel-stylesheet-compiler')

// convert a CSS file
const rpxRatio = 750
const sst = new StyleSheetTransformer(PATH, CONTENT, CLASS_PREFIX, rpxRatio)

// get the CSS output
const ss = sst.getContent()

// get the source map if needed
sst.toSourceMap()

// free it if the source map is not required
sst.free()

Dependencies

~14–25MB
~381K SLoC