Fireship · @fireship

PostCSS in 100 Seconds

Uploaded September 2, 2021 · Length 2:13

PostCSS in 100 Seconds

Summary

postcss explained as a tool for transforming styles with javascript plugins for website development.

  • postcss
  • css transformation
  • javascript plugins
  • website development
  • css build tool

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    post css a tool for transforming styles

  2. 0:03

    with javascript plugins when you build a

  3. 0:05

    website the css code you write is rarely

  4. 0:08

    the code that you actually want to ship

  5. 0:09

    to the browser the developer wants to

  6. 0:11

    write code with modern features that

  7. 0:13

    maximize productivity but end users want

  8. 0:15

    fast minified code that supports legacy

  9. 0:18

    browsers post css is a build tool that

  10. 0:20

    makes everybody happy it can take a css

  11. 0:22

    file and convert it to an abstract

  12. 0:24

    syntax tree then provides an api where

  13. 0:27

    plugins written in javascript can

  14. 0:29

    produce a different output for example

  15. 0:31

    by using the auto prefixer plugin you'll

  16. 0:33

    never have to worry about writing vendor

  17. 0:34

    prefixes on your styles ever again or

  18. 0:37

    with the preset enb plugin you can write

  19. 0:39

    modern css while post css will

  20. 0:41

    automatically add the polyfills needed

  21. 0:43

    to support your targeted browsers or you

  22. 0:46

    might drop in a tool like style and to

  23. 0:48

    detect issues before they break your ui

  24. 0:50

    and there are tons of other useful

  25. 0:51

    plugins in the ecosystem to try out and

  26. 0:53

    if none of them meet your needs you can

  27. 0:55

    always build your own you might use the

  28. 0:56

    plugin api to find all the color

  29. 0:58

    declarations in the code then write some

  30. 1:00

    javascript to transform them to a

  31. 1:02

    different format you probably already

  32. 1:03

    use post css without even realizing it

  33. 1:06

    as it generates more npm downloads than

  34. 1:08

    typescript and webpack can bind it's

  35. 1:10

    used under the hood by frameworks like

  36. 1:12

    veed and next js to provide a

  37. 1:14

    streamlined developer experience and

  38. 1:16

    it's also used by some of the world's

  39. 1:17

    most popular websites like wikipedia and

  40. 1:19

    twitter now despite its name it also

  41. 1:22

    handles pre-processing similar to

  42. 1:24

    frameworks like sas less and stylus it

  43. 1:26

    can be used in conjunction with existing

  44. 1:28

    preprocessors or as an alternative to

  45. 1:30

    them altogether if you want to write css

  46. 1:33

    with nesting or mixins there are plugins

  47. 1:35

    that can enable those features in your

  48. 1:37

    code so it's like configuring your own

  49. 1:39

    css preprocessor by including your

  50. 1:41

    favorite features and avoiding the ones

  51. 1:43

    that tend to lead to bad practices on

  52. 1:45

    top of that it tends to produce much

  53. 1:47

    faster build times to get started

  54. 1:49

    install it into your project with npm

  55. 1:51

    then create a post css config file

  56. 1:54

    inside of it customize the array of

  57. 1:55

    plugins that you want to use and finally

  58. 1:57

    run it from the command line as part of

  59. 1:59

    your build process to make your styles