Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Yes we CSS! Awesome workflows with PostCSS

Yes we CSS! Awesome workflows with PostCSS

Michele Mazzuco

September 27, 2016

Transcript

43 slides
  1. Why do we use preprocessors? • CSS templating (mix your

    code with styles) • Make your CSS dry • Save you time • CSS files more organised (indentation) • Vars, Mixins and functions
  2. Monolithic Lib sass
 110 files, 21 300 LOC of C++

    Stylus 72 files, 7 900 LOC Less 105 files, 9 800 LOC
  3. More readability .class-name { @include display-flex; @include flex-direction(row); @include flex-wrap(wrap);

    } .class-name { display: flex; flex-direction: row; flex-wrap: wrap; }
  4. More readability .class-name { @include display-flex; @include flex-direction(row); @include flex-wrap(wrap);

    } .class-name { display: flex; flex-direction: row; flex-wrap: wrap; }
  5. Autoprefixer .class-name { display: flex; } .class-name { display: -webkit-box;

    display: -webkit-flex; display: -ms-flexbox; display: flex; } http://autoprefixer.github.io/
  6. Autoprefixer .class-name { display: flex; } .class-name { display: -webkit-box;

    display: -webkit-flex; display: -ms-flexbox; display: flex; } http://autoprefixer.github.io/
  7. CSSnext :root { --fontSize: 1rem; --spacer: 20px; } h1 {

    font-size: calc(var(--fontSize) * 2); padding: var(--spacer) 0; } http://cssnext.io/playground/
  8. PreCSS $green: #699e0e; $blue: #0e6b9e; .footer__button { @if 3 <

    5 { background: $green; } @else { background: $blue; } }
  9. CSSnano @charset “utf-8”;h1:before{margin:10px 20px;color:red;border-radius:16px;font- weight:normal;background-position:100% 100%} • Removes outdated vendor

    prefixes • Converts color values to shorter equivalents • Removes duplicate rules • Rebases z-index values • Removes unused definitions • ….
  10. Stylint site/scss/base/_layout.scss 22:3 ⾠ Expected empty line before nested... [stylelint]

    29:5 ⾠ Expected empty line before nested... [stylelint] 33:5 ⾠ Expected empty line before nested... [stylelint] site/scss/base/_header.scss 12:7 ⾠ Expected empty line before nested... [stylelint] 22:3 ⾠ Expected empty line before nested... [stylelint]
  11. Impossible with Sass and Less • CSSnext • Autoprefixer •

    PostCSS ColorBlind • CSS Modules • BEM linter • Do I use • and more…

More Decks by Michele Mazzuco

Other Decks in Technology