Skip to content

minify transform functions #75 #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Changelog

# v0.9.2

# v1.0.0

- [x] experimental minification : CSS transform module level 2
- [x] translate
- [x] scale
- [x] rotate
- [x] skew
- [x] perspective
- [x] matrix
- [x] matrix3d
- [x] keyframes
- [x] remove consecutive keyframes with the same name
- [x] reduce keyframe selector 'from' to '0%'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Thierry Bela
Copyright (c) 2023-present Thierry Bela

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ $ deno add @tbela99/css-parser
- convert nested css rules to legacy syntax
- generate sourcemap
- compute css shorthands. see supported properties list below
- experimental minification : css transform module level 2
- evaluate math functions: calc(), clamp(), min(), max(), round(), mod(), rem(), sin(), cos(), tan(), asin(), acos(),
atan(), atan2(), pow(), sqrt(), hypot(), log(), exp(), abs(), sign()
- inline css variables
Expand Down Expand Up @@ -96,7 +97,7 @@ Javascript module from cdn

<script type="module">

import {transform} from 'https://esm.sh/@tbela99/css-parser@0.9.0/web';
import {transform} from 'https://esm.sh/@tbela99/css-parser@1.0.0/web';


const css = `
Expand Down Expand Up @@ -159,6 +160,7 @@ Include ParseOptions and RenderOptions
- expandNestingRules: boolean, optional. convert nesting rules into separate rules. will automatically set nestingRules
to false.
- removeDuplicateDeclarations: boolean, optional. remove duplicate declarations.
- computeTransform: boolean, optional. compute css transform functions.
- computeShorthand: boolean, optional. compute shorthand properties.
- computeCalcExpression: boolean, optional. evaluate calc() expression
- inlineCssVariables: boolean, optional. replace some css variables with their actual value. they must be declared once
Expand All @@ -176,13 +178,18 @@ Include ParseOptions and RenderOptions
- src: string, optional. original css file location to be used with sourcemap, also used to resolve url().
- sourcemap: boolean, optional. preserve node location data.

> Misc Options
> Ast Traversal Options

- visitor: VisitorNodeMap, optional. node visitor used to transform the ast.

> Urls and \@import Options

- resolveImport: boolean, optional. replace @import rule by the content of the referenced stylesheet.
- resolveUrls: boolean, optional. resolve css 'url()' according to the parameters 'src' and 'cwd'
- resolveImport: boolean, optional. replace @import rule by the content of its referenced stylesheet.

> Misc Options
- removeCharset: boolean, optional. remove @charset.
- cwd: string, optional. destination directory used to resolve url().
- visitor: VisitorNodeMap, optional. node visitor used to transform the ast.
- signal: AbortSignal, optional. abort parsing.

#### RenderOptions
Expand Down Expand Up @@ -701,6 +708,8 @@ for (const {node, parent, root} of walk(ast)) {

## Minification

- [x] minify keyframs
- [x] minify transform
- [x] evaluate math functions calc(), clamp(), min(), max(), round(), mod(), rem(), sin(), cos(), tan(), asin(),
acos(), atan(), atan2(), pow(), sqrt(), hypot(), log(), exp(), abs(), sign()
- [x] multi-pass minification
Expand Down
Loading