Skip to content

mangling of CSS variables (custom properties)? #51

@tameraydin

Description

@tameraydin

Hi, thanks for this project!

Although the focus of plugin's is clearly class-names only, it would be nice if it also mangles CSS variables (custom properties) optionally.

:root {
  --l-long-variable-names: 1px;
}
... {
  padding: var(--l-long-variable-names)
}

->

:root {
  --a: 1px;
}
... {
  padding: var(--a)
}

Practically below change will enable it:

-    classnameRegex = new RegExp(`\\\.(${opts.classNameRegExp})`, 'g');
+    classnameRegex = new RegExp(`\(?:\.?|--)(${opts.classNameRegExp})`, 'g');

If you are willing to introduce this, happy to create a PR with tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions