Skip to content

Commit

Permalink
feat: Optimize the output of the CSS (#1379)
Browse files Browse the repository at this point in the history
The minified CSS is quite heavy, and a large part of the wright is due
to media queries. I think we can do a lot better. The first optimization
is to regroup media queries from the cssModulesUtils and nativeUtils
mixins. Before this commit, cozy-ui.min.css took 129kb, and after, it
tooks now 123kb.
  • Loading branch information
nono authored Feb 10, 2020
1 parent 61e15c1 commit 56b04fd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions stylus/tools/mixins.styl
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,26 @@ global(selector, placeholder, type = extend)
{placeholder}() // @stylint ignore

cssModulesUtils(props, breakpoints)
for kProp, vProp in props
for kBp, vBp in breakpoints
if vBp == ''
for kBp, vBp in breakpoints
if vBp == ''
for kProp, vProp in props
:global(.u-{vProp})
{kProp}()
else
@media (max-width: rem(lookup('BP-'+kBp)))
else
@media (max-width: rem(lookup('BP-'+kBp)))
for kProp, vProp in props
:global(.u-{vProp}-{vBp})
{kProp}()

nativeUtils(props, breakpoints)
for kProp, vProp in props
for kBp, vBp in breakpoints
if vBp == ''
for kBp, vBp in breakpoints
if vBp == ''
for kProp, vProp in props
.u-{vProp}
{kProp}()
else
@media (max-width: rem(lookup('BP-'+kBp)))
else
@media (max-width: rem(lookup('BP-'+kBp)))
for kProp, vProp in props
.u-{vProp}-{vBp}
{kProp}()

Expand Down

0 comments on commit 56b04fd

Please sign in to comment.