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

bin+lib glass-easel-stylesheet-compiler

The stylesheet compiler of the glass-easel project

8 releases (4 breaking)

new 0.5.3 May 15, 2024
0.5.2 May 13, 2024
0.4.0 Apr 9, 2024
0.3.1 Mar 1, 2024
0.1.1 Feb 3, 2023

#4 in #style-sheet

Download history 133/week @ 2024-02-14 24/week @ 2024-02-21 171/week @ 2024-02-28 18/week @ 2024-03-06 4/week @ 2024-03-13 2/week @ 2024-03-27 75/week @ 2024-04-03 45/week @ 2024-04-10 216/week @ 2024-05-01 124/week @ 2024-05-08

340 downloads per month

MIT license

50KB
1K 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

~13–25MB
~400K SLoC