Skip to content

New css module scope #123

@tbela99

Description

@tbela99

Add shortest scope which produces short class names

import {ModuleCaseTransformEnum, ModuleScopeEnumOptions, transform} from "@tbela99/css-parser";

const css = `
.className {
  background: red;
  color: yellow;
}

.subClass {
  composes: className;
  background: blue;
}
`;

const result = await transform(css, {
        beautify: true,
    module: ModuleScopeEnumOptions.Shortest | ModuleScopeEnumOptions.ICSS | ModuleCaseTransformEnum.DashCaseOnly
});

console.debug(result.code);

result

:export {
 class-name: a;
 sub-class: b a;
}
.a {
 background: red;
 color: #ff0
}
.b {
 background: blue
}
console.error(result.mapping);
{
  "class-name": "a",
  "sub-class": "b a",
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions