css-custom-property-extractor
v0.1.6
Published
Extract css custom properties as constant values that can be used in JS.
Downloads
12
Maintainers
Readme
Intro
- Parse css custom properties and output typescript files.By importing the output typescript files ,custom properties can be used type-safely in various libraries.
- Supports
css
andsass
andless
.
Usage
- Install as
devDependencies
npm i -D css-custom-property-extractor
- For example. Parsing ./samples/scss/bootstrap.scss outputs the following typescript file.
npx ccpe -i ./samples/scss/bootstrap.scss
/**
* #0d6efd;
*/
export const bsBlue = "var(--bs-blue)"
/**
* #6610f2;
*/
export const bsIndigo = "var(--bs-indigo)"
/**
* #6f42c1;
*/
export const bsPurple = "var(--bs-purple)"
...
- Import and use the output typescript file.
Command options
| option | description |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -o <path> | output path. |
| -i,--include | include path (glob pattern). (default */.?(css | scss | sass | less)) |
| -e,--exclude | exclude path (glob pattern). |
| -v,--vite <path | false> | Specify the relative path to vite.config.Read the css-preprocessoroptions property from vite.config
. (default false) |