Skip to content
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

Minify class names in production #175

Closed
steadicat opened this issue Nov 14, 2017 · 1 comment
Closed

Minify class names in production #175

steadicat opened this issue Nov 14, 2017 · 1 comment
Labels
enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: help 🆘 Help is needed
Milestone

Comments

@steadicat
Copy link

Do you want to request a feature or report a bug?
Feature.

What is the current behavior?
In production, generated class names are of the form _{variableName}__{hash}, same as in development mode.

What is the expected behavior?
They should just be _{hash}. This will save some bytes and look cleaner, by not leaking internal variable names into the generated markup and CSS. At least make this an option.

@satya164 satya164 added enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed rfc labels Nov 21, 2017
@zamotany zamotany added this to the v0.5.0 milestone Nov 22, 2017
@zamotany
Copy link
Contributor

zamotany commented Nov 22, 2017

For assignee:
This should be configurable as a babel preset options like minifyClassnames and should generate short hash (6 chars should be fine) from _{variableName}__{hash} to ln{newHash} where ln is our prefix.

The code should probably be done here https://github.com/callstack/linaria/blob/master/src/babel/preval-extract/prevalStyles.js#L63

You can get the options from state.opts.myOption.

@zamotany zamotany added needs: help 🆘 Help is needed and removed rfc labels Nov 22, 2017
zamotany pushed a commit that referenced this issue Dec 5, 2017
* feat: added option to minify classnames

* test: added test for minifyClassnames fn

* test: updated name of test and also checking for lenght

* fix: slugify

* feat: added short-hash and used instead of slugify

* docs: added readme and jukben into contributors

* fix: test regex

* fix: short-hash should be in deps not devDeps

* revert prettier formatting in package.json

* remove rebase leftovers

* fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: help 🆘 Help is needed
Projects
None yet
Development

No branches or pull requests

4 participants