myFavShrimp / turf

Macro based compile-time SCSS transpilation, CSS minification, and class name uniquification toolchain inspired by CSS modules.
MIT License
50 stars 2 forks source link

[Feature Request] Custom dictionary for minification #12

Open kitsuniru opened 10 months ago

kitsuniru commented 10 months ago

Hi, i would like turf to use my custom symbol dictionary, for example: +, _, - and some like this

myFavShrimp commented 10 months ago

Hey, I'm not sure what exactly you mean. Can you please explain what this feature should do and how you are planning to use it?

kitsuniru commented 10 months ago

@myFavShrimp at the current moment turf generates unique id for each style as a random integer, but i want to use custom symbols, for example, abcdefgh instead of 0123456789 proposal:

[package.metadata.turf.class_names]
template = "<id>"
id_dictionary = ["a","b","c","d","e","f","g","v"]
id_bounds = [3,16]

where:

result: image

kitsuniru commented 10 months ago

also, for support wide range of possible symbols in dictionary, we can generate resulting css selectors like this:

[class="{{ generated_name }}"] {{ body_of_style }} [id="{{ generated_name }}"] {{ body_of_style }}

instead of:

.{{ generated_name }} {{ body_of_style }} #{{ generated_name }} {{ body_of_style }}

kitsuniru commented 10 months ago

as a result, we can minify our style names to real shit like this: image

take a look at <div id = "#">, it was stylized with strange (and sometimes mindbreaking) id - #

js selectors will be like: ##. what's really incredible and a little bit scary