level up with post css - developer summit€¦ · postcss.plugin(['myplugin'], options...
TRANSCRIPT
![Page 1: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/1.jpg)
Rakesh Menon
Level Up with Post CSS
![Page 2: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/2.jpg)
Level up with
![Page 3: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/3.jpg)
Rakesh Menon @rakeshmenon13
![Page 4: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/4.jpg)
I’ve seen before! ツ
The PostCSS logo looks like something
![Page 5: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/5.jpg)
![Page 6: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/6.jpg)
Key Takeaways
from this session
•
•
•
•
•
![Page 7: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/7.jpg)
![Page 8: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/8.jpg)
![Page 9: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/9.jpg)
Evolution
![Page 10: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/10.jpg)
Evolution cycle
![Page 11: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/11.jpg)
•
•
•
CSS (Cascading Style Sheets)
![Page 12: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/12.jpg)
.section > .inner-section >
.inner-section-header > .inner-
section-headers-heading > .the-
text-inside-it > .which-also-
has-words {
/* I did a bad job */
}
CSS (Cascading Style Sheets)
![Page 13: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/13.jpg)
![Page 14: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/14.jpg)
Preprocessor
s
•
•
•
![Page 15: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/15.jpg)
![Page 16: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/16.jpg)
The Dark Side
•
•
•
![Page 17: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/17.jpg)
![Page 18: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/18.jpg)
What is PostCSS?
![Page 19: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/19.jpg)
What is PostCSS - not??
![Page 20: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/20.jpg)
PostCSS is not!
•
•
![Page 21: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/21.jpg)
•
•
PostCSS is not!
![Page 22: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/22.jpg)
•
•
PostCSS is not!
![Page 23: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/23.jpg)
•
•
PostCSS is not!
![Page 24: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/24.jpg)
So what exactly is PostCSS?
![Page 25: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/25.jpg)
![Page 26: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/26.jpg)
Andrey Sitnik
![Page 27: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/27.jpg)
Steps involved in building a CSS tool
•
•
•
•
![Page 28: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/28.jpg)
PostCSS handles the tedious
stuff!
•
•
•
•
![Page 29: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/29.jpg)
PostCSS consists of…
![Page 30: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/30.jpg)
Abstract Syntax Tree (AST)
![Page 31: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/31.jpg)
Abstract Syntax Tree (AST)
![Page 32: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/32.jpg)
let postcss = require('postcss');
Usage
let css = /* read css file with FS */;
postcss([ plugin1, plugin2(options), ..])
.process(css)
.then( result => console.log(result.css) /* or write the css to disk */ );
![Page 33: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/33.jpg)
postcss.plugin(['myplugin'], options => {
PostCSS Plugin
/* Use options */
return css => {
/* process css */
};
});
![Page 34: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/34.jpg)
Overview of how PostCSS works
![Page 35: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/35.jpg)
/* Root */ .foo { /* Rule */ color: pink; /* Declaration */ } /* AtRule */ @media (min-width: 20rem) { .foo { color: orange; } }
![Page 36: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/36.jpg)
/* Root */ .foo { /* Rule */ color: pink; /* Declaration */ } /* AtRule */ @media (min-width: 20rem) { .foo { color: orange; } }
![Page 38: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/38.jpg)
root.walkRules(); rule.walkDecls(); decl.cloneBefore(); comment.remove(); // ...
![Page 39: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/39.jpg)
•
•
![Page 40: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/40.jpg)
PostCSS is also….
![Page 41: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/41.jpg)
Let’s create a plugin!
![Page 42: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/42.jpg)
Fallback plugins
![Page 43: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/43.jpg)
:
Fallback plugins
![Page 44: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/44.jpg)
{ all: initial; }
:
Fallback plugins
![Page 45: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/45.jpg)
.element:container(width >=
100px <= 300px) {}
:
Fallback plugins
![Page 46: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/46.jpg)
•
•
•
•
Non-standard keywords….
Confusion?
![Page 47: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/47.jpg)
•
•
•
•
•
Non-standard keywords….
Confusion?
![Page 48: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/48.jpg)
Non-standard keywords….
Confusion?
![Page 49: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/49.jpg)
Utilities
•
•
![Page 50: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/50.jpg)
![Page 51: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/51.jpg)
![Page 52: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/52.jpg)
CSS Next?
![Page 53: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/53.jpg)
CSS Next?
![Page 54: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/54.jpg)
CSS Next?
•
•
![Page 55: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/55.jpg)
Analytical Tools
•
•
•
•
•
![Page 56: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/56.jpg)
Other important tools
•
•
•
•
•
![Page 57: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/57.jpg)
![Page 58: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/58.jpg)
Evolution cycle
![Page 59: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/59.jpg)
Evolution cycle
![Page 60: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/60.jpg)
Choosing the Stack
•
•
•
•
•
![Page 61: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/61.jpg)
Choosing the Stack
•
•
•
![Page 62: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/62.jpg)
•
•
•
•
Choosing the Stack
![Page 63: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/63.jpg)
•
•
•
•
Summing it up!
![Page 64: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/64.jpg)
![Page 65: Level Up with Post CSS - Developer Summit€¦ · postcss.plugin(['myplugin'], options => { PostCSS Plugin /* Use options */ return css => { /* process css *](https://reader031.vdocument.in/reader031/viewer/2022013022/5f5fdd72cd909c3af36e72ca/html5/thumbnails/65.jpg)
Questions