Learn how to power-up your CSS with PostCSS

  Рет қаралды 81,193

Kevin Powell

Kevin Powell

Күн бұрын

If you're going to use the preset-env, I'd strongly recommend adding the PostCSS Language Support plugin to VS Code, so that it recognizes the CSS you are writing: marketplace.visualstudio.com/...
PostCSS is an absolutely amazing tool, so let's see how we can use it!
🔗 Links
✅ PostCSS: postcss.org
⌚ Timestamps
00:00 - Introduction
01:18 - The plugins we'll be setting up
01:32 - Installing PostCSS
04:17 - Installing our first plugin
05:06 - Adding the PostCSS config file
06:25 - Using our first plugin
07:28 - Setting up the command in our package.json
09:12 - Using the command
10:01 - Getting PostCSS to watch our files
12:09 - Installing cssnano and preset-env
14:12 - Exploring preset-env
15:37 - Setting up options for a plugin
17:57 - Custom property media queries with preset-env
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZbin channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 131
@larjasoul
@larjasoul 2 жыл бұрын
Your channel is an absolute gold mine. Thank you so much for creating the content you do.
@Nounearthlyglow
@Nounearthlyglow 2 жыл бұрын
Always great to find a fresh video by a reliable creator ESPECIALLY when you only find out about a subject/concept just a day prior to the video being released! Thank you. I still have more to learn, but this is a great start.
@sumitkkundu
@sumitkkundu 2 жыл бұрын
Thank you Kevin. I was actually looking for a tutorial on PostCSS initial setup process. This video will help me a lot. Please make more videos on PostCSS features and benefits. Thank you once again.
@cindykee3719
@cindykee3719 2 жыл бұрын
Thank you SO MUCH for doing this video! I have been wanting to know how to use PostCSS for a little while now and how I have the step-by-step instructions right here to use in my next project! This is great!
@naps7039
@naps7039 2 жыл бұрын
I learned a lot from your videos fam, thank you and keep up the great work
@paulwdoyle
@paulwdoyle 2 жыл бұрын
WOW! ... You've just changed my life!!!... Thank you so much, your videos are a wonderful resource.
@siddiqahmed3274
@siddiqahmed3274 2 жыл бұрын
Css supercharged 🔥♥️ Thanks KING♥️ I would also love to see some more videos or maybe a sort of big project of jamstack using its all important features. I don't know much about it except for your video😅
@k3tna
@k3tna 2 жыл бұрын
Amazing. Thanks, it couldn't have been better explained.
@mdkawsarislamyeasin4040
@mdkawsarislamyeasin4040 2 жыл бұрын
Need more videos like this! Plz sir, create a full playlist for postcss . And show other plugging that how works !
@devchaudhary78
@devchaudhary78 2 жыл бұрын
Great explanation kevin🙌
@TechTalesandBeyond
@TechTalesandBeyond 2 жыл бұрын
I just loved it... Really informative
@sevsol88
@sevsol88 2 жыл бұрын
Perfect Timing for me yesterday I started looking into postCSS tutorials and who better than Kevin
@yangenmanuel2659
@yangenmanuel2659 2 жыл бұрын
If anyone tell me that this man created CSS I'll belive it
@KevinPowell
@KevinPowell 2 жыл бұрын
Haha, no, just been writing it for *a long* time 😅
@TheZebrAlpha
@TheZebrAlpha 2 жыл бұрын
I thought that was @Wes Bos's dad?
@varunc1231
@varunc1231 2 жыл бұрын
one of the people who has worked on css - kzbin.info/www/bejne/oX_doKate66Ib68
@electricrocodile8533
@electricrocodile8533 Жыл бұрын
Believe*
@adamsDevArt
@adamsDevArt 2 жыл бұрын
Thank you Kevin, I always enjoy your videos! All this video I thought why not do it all with sass, am i missing something? 🙏🏼
@matiasribero9721
@matiasribero9721 2 жыл бұрын
Would love a short to see the steps compressed in less than a minute!
@maximcoppieters
@maximcoppieters 2 жыл бұрын
PostCSS in 100 seconds -fireship (soon maybe)
@matiasribero9721
@matiasribero9721 2 жыл бұрын
@@maximcoppieters He did it already lmao
@maximcoppieters
@maximcoppieters 2 жыл бұрын
@@matiasribero9721 Oh, of course he did :] (just found it)
@laceyhunter2209
@laceyhunter2209 2 жыл бұрын
Incredible, Kevin.
@MrBlaq
@MrBlaq 2 жыл бұрын
Awesome. Thank you! Would you be able to post the occasional postcss vid highlighting what plugins you use in your workflow?
@doyouwatchanime58
@doyouwatchanime58 2 жыл бұрын
whoa i just started learning css and it looks cool aldready and that writing css in diffrent kind of folders and just made choose from previous ones and make new css in one touch
@SlayDota9
@SlayDota9 2 жыл бұрын
omg the way you smile Kevin is so nice
@mdkawsarislamyeasin4040
@mdkawsarislamyeasin4040 2 жыл бұрын
Please create more PostCSS video tutorials! Please show us more plugging and advanced use of postcss! Thank you for this video also! love from Bangladesh 🇧🇩
@ahnafalnafis
@ahnafalnafis Жыл бұрын
🇧🇩
@e11world
@e11world 2 жыл бұрын
This is very interesting. I always use SCSS so this feels like a good maybe for just .css files but still great to know. Thanks Kevin!
@devbash
@devbash 2 жыл бұрын
You can use both!
@pyprem
@pyprem 2 жыл бұрын
Awesome video! Just a small note: you actually don't need to do npm init if you just want to fetch some libraries. You can just npm install in an empty folder.
@michaelfaith
@michaelfaith 2 жыл бұрын
Great video. And i also love Sass! Would love some dedicated Sass content. 🙌
@andriilukianenko8106
@andriilukianenko8106 2 жыл бұрын
Awesome!
@valeriousmonk654
@valeriousmonk654 2 жыл бұрын
More postCSS plz
@AdamFiregate
@AdamFiregate 2 жыл бұрын
Excellent, Kevin! 🙏Could you do a series on PostCSS? 😇 Thanks.
@KevinPowell
@KevinPowell 2 жыл бұрын
Any specific things you'd like to see?
@israelssantanna
@israelssantanna 2 жыл бұрын
I don't know about him, but I would like to see everything! Hahaha But seriously, a postcss beginner series (installation/configuration/{most used,basic} plugins) would be wonderful!
@AdamFiregate
@AdamFiregate 2 жыл бұрын
I usually use PostCSS with SCSS, cssnano, and Autoprefixer. I don't have much knowledge beyond these. Any other things can be interesting, plugins, etc. Thanks!
@zagbaleeric3706
@zagbaleeric3706 2 жыл бұрын
I love your videos thanks a lot of....
@tamantaman
@tamantaman 2 жыл бұрын
Thank you very mucho
@lucienchu9649
@lucienchu9649 2 жыл бұрын
Morning Kevin, finally sth I can help, in VS code, to split a tab on right hand side, the short cut is ctrl + \, hope this could help :).
@JonRonnenberg
@JonRonnenberg 2 жыл бұрын
It's interesting that you put components before utilities. I use BEM and always put utilities before my blocks/components, since I want a component to always "win" over utilities. But maybe I have been doing it wrong all this time. What is your rational for putting utilities at the end?
@EpicphoneGamer
@EpicphoneGamer 2 жыл бұрын
Thank you for the tutorial! As a newbie to all of this, this feels waaay more complicated than SASS. When should I prefer postCSS over SASS?
@EpicphoneGamer
@EpicphoneGamer 2 жыл бұрын
Oh and another question: Do I need PostCSS when using the React framework? Is it compatible, an useful addition or are a lot of postCSS features obsolete because of built-in features in React?
@jerodwilhoit3582
@jerodwilhoit3582 2 жыл бұрын
Love the video and can't wait for the Sass course. Quick question, do you link the public/style.css in your html or the src/style.css?
@IainSimmons
@IainSimmons 2 жыл бұрын
public, that's the whole point, that you get a single, minified, compiled and browser supported version of your CSS
@ArchaicCreationsbp
@ArchaicCreationsbp 2 жыл бұрын
@@IainSimmons so just to clarify, "source" is the one we use to build our website and "public" is for the one that people view on their browsers right?
@IainSimmons
@IainSimmons 2 жыл бұрын
@@ArchaicCreationsbp yup
@mod_123_
@mod_123_ 2 жыл бұрын
Any tips for cross browser css other than autoprefixing? Still new to it
@Jxerot
@Jxerot 2 жыл бұрын
Why use PostCSS if less / sass / scss can do exactly the same? Got my phpstorm + less compiler + autoprefix + minify for years now :-) Same same but different? Why should I use postCSS instead of my setup?
@carstenruppert8443
@carstenruppert8443 2 жыл бұрын
Great work but can i use global variables from Color.css in navbar.css as in @use like sass ?
@josvelema2362
@josvelema2362 2 жыл бұрын
Cool stuff! If you have the patience for the setting it up you get a clean and organised workflow , can't wait for your SASS course ;) . Also like that you can use future-CSS , what got me thinking ; can it do subgrid?
@nextentrepreneur9288
@nextentrepreneur9288 2 жыл бұрын
When referring to "writing future css", it means writing css syntax that might be natively adopted by browsers which then gets compiled down to current css. This means that it's all current css at the end and features that are not yet supported by css can't be used as far as I know (unless you mess with the browsers' flags) _Syntactic sugar_ might be the perfect expression to describe this "future css" imo
@moemenchalouati4182
@moemenchalouati4182 2 жыл бұрын
I've literally been stuck all day trying to figure out how to use postcss with parcel man
@palamz7027
@palamz7027 2 жыл бұрын
Love you videos! For how long have you been coding?
@KevinPowell
@KevinPowell 2 жыл бұрын
Started as a hobby in 1997 or 1998... did it on and off for, and started to take it seriously in... 2006 or 2007 maybe, and started teaching it in 2014 :)
@pipegoods
@pipegoods 8 ай бұрын
Where i can read all features order by stage?
@dieweltentdecker5878
@dieweltentdecker5878 2 жыл бұрын
Finally. Do you recommend using parcel or gulp (or how it is called)?
@KevinPowell
@KevinPowell 2 жыл бұрын
Both are great. Depends on your needs. Vite is pretty great as well, which uses Rollup.
@_anjianto
@_anjianto 2 жыл бұрын
Do you have a video for handling blue and purple color sir? I always get stuck with this colors, on Chrome and Firefox this color like difference. If i use purple on chrome, firefox will output as blue and when i use blue on chrome, firefox will output as purple. Which one is correct?
@pooriagholami7086
@pooriagholami7086 2 жыл бұрын
thnak you for your useful channel, but why we should use post-css when we can use sass(scss) instead!
@svenyboyyt2304
@svenyboyyt2304 10 ай бұрын
Do you have to use require and module.exports or can you use ES modules?
@amarg26
@amarg26 2 жыл бұрын
Also can you able to make another tutorial on postcss-uncss on a mid size project?
@nomad100hd
@nomad100hd 2 жыл бұрын
It's still control+c on Mac and Linux.
@shortsquake101
@shortsquake101 2 жыл бұрын
i love your videos my uncle
@varunjathin
@varunjathin 2 жыл бұрын
Can you please do a video on removing unused css from the project? Thank you
@jacoblockwood4034
@jacoblockwood4034 2 жыл бұрын
11:45 If you are on a mac it is control + C
@okopyl
@okopyl 2 жыл бұрын
on mac it's control c as well
@jenstornell
@jenstornell 2 жыл бұрын
It's CTRL + C on both Mac and PC to terminate the terminal. 😊
@AlfredTuinmanOurManInIndia
@AlfredTuinmanOurManInIndia 9 ай бұрын
Postcss does not seem to be able to cope with ES6 so one would need to use Rollup (or similar)
@alexfrozen
@alexfrozen Жыл бұрын
You can use Ctrl+L instead of "clear" in terminal)
@amarg26
@amarg26 2 жыл бұрын
PostCSS or Stylelint which to choose what ?
@DanielRios549
@DanielRios549 2 жыл бұрын
I still prefer SASS, but this @custom-media is fantastic, even with SASS I will change the mixins I use for breakpoinst to custom media queries, it is better to use them in the other files, no need to import the file with the mixins and it is not an @include, but a @media.
@8ack2Lobby
@8ack2Lobby 2 жыл бұрын
My VS Code kept showing syntax errors until I installed the extension "PostCSS Language Support".
@elitedire4k
@elitedire4k Жыл бұрын
Can this work with .scss files or no. Also is this what you use for all your projects?
@programming3043
@programming3043 2 жыл бұрын
Can we use sass along with postcss, idk why I would do that. PostCSS is similar to tailwind, I guess tailwind uses postCSS under the hood
@sanmeetsingh4
@sanmeetsingh4 2 жыл бұрын
CSS == KEVIN CSS evaluates Awesomly true 😊 [ Kevin and me are besties]
@mohamedyamani8502
@mohamedyamani8502 2 жыл бұрын
Great video. Just one question, I've worked with PostCSS before but I just installed postcss-cli without postcss, is that okay?
@IainSimmons
@IainSimmons 2 жыл бұрын
It probably installs postcss as one of its own dependencies
@mohamedyamani8502
@mohamedyamani8502 2 жыл бұрын
@@IainSimmons so it suffices to install only postcss-cli + its plugins, correct?
@IainSimmons
@IainSimmons 2 жыл бұрын
@@mohamedyamani8502 yes, either would work, but I think it makes sense to include postcss and be explicit about it
@splendourb1477
@splendourb1477 6 ай бұрын
Hi! Please I need your. My output file returns '@import 'files'' instead of the content of the files. How do I fix it?
@shaijuelayidath
@shaijuelayidath 11 ай бұрын
Hello Sir, I would like to use PostCSS to generate minified files from all the CSS files in a directory. Can you advice how can i achive it. I was trying the follwing NPM scripts and failed. Thanks in Advance! "scripts": { "postcss": "assets/css/*.css > assets/css/*.min.css" }
@The-Dev-Ninja
@The-Dev-Ninja 2 жыл бұрын
👍
@francesca5295
@francesca5295 Жыл бұрын
i'm not sure why but when i try to run the postcss:watch I get the folder I get the file.css buy inside it's the same as the import it just shows the @import.... anyone can help?
@med219
@med219 2 жыл бұрын
Very well to improve organisation in a big project with many developers. But in a little project its useless and a waste of time. Why turn simple thing that work well to something more confusing…good vidz
@mathiasmatanda8848
@mathiasmatanda8848 2 жыл бұрын
CSS knows Kevin
@KevinPowell
@KevinPowell 2 жыл бұрын
😂😂
@DeltaNrOne
@DeltaNrOne 2 жыл бұрын
I have one word “wow”
@JonHogg
@JonHogg 2 жыл бұрын
I was lost at open up Terminal. Where is that?!
@lewis4929
@lewis4929 Жыл бұрын
theres a big issues with this method in that postcss-import cannot handle root css variables and if you're importing all your stylesheets into a single css file, the styling rules get duplicated twice. from what i can see, its unsolvable.
@J90JAM
@J90JAM 2 жыл бұрын
Native CSS nesting isn't supported yet or does it not matter because it gets converted?
@KevinPowell
@KevinPowell 2 жыл бұрын
It gets converted to what the browser can understand :)
@deniskotov
@deniskotov 2 жыл бұрын
I still don't understand why I need postcss... Is it helpful when you work on big projects?
@Nitrxgen
@Nitrxgen 2 жыл бұрын
This is the tiniest contribution ever I know but since you make a point about saving keystrokes, cls is shorter than clear
@IainSimmons
@IainSimmons 2 жыл бұрын
Or Command + K on Mac when the terminal is focused, or add a keybinding for Windows: { "key": "ctrl+k", "command": "workbench.action.terminal.clear", "when": "terminalFocus" },
@shayanfaghihi
@shayanfaghihi 2 жыл бұрын
I know that there is the @import ability in SCSS, but you've mentioned that we shouldn't use that in CSS. Could you please make it more clear why?
@danielherrman9228
@danielherrman9228 2 жыл бұрын
As far what I understood... It is not relevant anymore. You should learn how to use @use and @forward instead... as @import will not be supported since october 2022. Can't get my head around... Does not make much sense to me as it worked very well and was very easy to use + DRY principal :) With this update it is way more time consuming (Iguess).
@herrlindner
@herrlindner 2 жыл бұрын
Wondering if there's any advantage over SCSS? 🤔
@IainSimmons
@IainSimmons 2 жыл бұрын
I have a feeling it is faster, but also I guess you are learning to write real CSS, even if it's features that aren't yet available in most/some browsers.
@herrlindner
@herrlindner 2 жыл бұрын
@@IainSimmons Wait, what isn't real about SCSS? :o :D
@IainSimmons
@IainSimmons 2 жыл бұрын
@@herrlindner haha yeah maybe poor choice of words. But it's similar to how some JS frameworks add a lot of stuff over the top of (abstracting) plain, vanilla JS. People learn those patterns, sometimes without learning the underlying native patterns/APIs. Example in this video was trying to nest selectors in the SCSS way, instead of with the ampersand which will eventually make it to the CSS core. Also, we should probably be learning CSS properties instead of Sass variables and native CSS functions like calc where possible. I know there are other differences, but I expect at one point you'll be able to do pretty much everything in native CSS and won't really need SCSS, similar to how we don't really need jQuery anymore since you can do it all with equivalent vanilla JS patterns.
@herrlindner
@herrlindner 2 жыл бұрын
@@IainSimmons thanks for your time and explanation buddy
@adarshchakraborty
@adarshchakraborty 2 жыл бұрын
Sass better?
@kabahblog
@kabahblog 2 жыл бұрын
It is better parcel or postcs ?
@KevinPowell
@KevinPowell 2 жыл бұрын
You can use Parcel along with PostCSS. Here I was using the PostCSS CLI to keep things simple, but you could use it with something like parcel to also have other stuff in your build process as well.
@jellycoding
@jellycoding 2 жыл бұрын
But you still want to run your _Live Server_ at the same time? And I guess it works great?
@KevinPowell
@KevinPowell 2 жыл бұрын
No reason live server wouldn't work. If you're using npm scripts or other build tools you could use it with browser sync as well
@b391i
@b391i 2 жыл бұрын
This Is Joe Say Hi Joe 🤣
@KajahaX
@KajahaX 2 жыл бұрын
11:50 it’s ctrl + c
@tumon001
@tumon001 2 жыл бұрын
Looks hard
@valeriousmonk654
@valeriousmonk654 2 жыл бұрын
using bem in postcss needs a lot of configurations :(
@izexi
@izexi 2 жыл бұрын
y dont just use SASS? omg. Lot of steps to make it work...
@abhijitbarman4401
@abhijitbarman4401 2 жыл бұрын
Some days ago I was thinking why Kevin yet not made video on PostCSS
@john-xb6xj
@john-xb6xj 2 жыл бұрын
I wonder if I got SASS tutorial in this channel
@KevinPowell
@KevinPowell 2 жыл бұрын
I have a bunch! Just search for Kevin Powell Sass and they should show up :)
@user-tu3te6cq6p
@user-tu3te6cq6p Жыл бұрын
thx for Ukraine ! This video is very helpful!
@arar445
@arar445 2 жыл бұрын
first to comment yaaaaaayy =D
@learnfronteasy9642
@learnfronteasy9642 2 жыл бұрын
i'm teaching Tailwind css in persian language
@Stoney_Eagle
@Stoney_Eagle 2 жыл бұрын
There is sooo much in this rabbithole, imagine having to import 100+ files manually 🤣 Nope just configure it to find all the files for you with a regular expression no biggie 😉 If you leave the background purple, I'll leave a like haha.
@darthtorus9341
@darthtorus9341 2 жыл бұрын
Just an FYI: you don't need to put semicolons at the end of every line in JS any longer. Obviously for consistency, keep doing it, but for future JS files, you don't need them.
@pbznt
@pbznt 2 жыл бұрын
Dear Kevin, I love your channel, I sent you an email about something that you might want to try to reproduce and try to fix! Please take a look at your spam folder, object is about 'Canadian company'. Well, thank you for all those free videos on KZbin. You help many people and your channel is great!
@alimantado373
@alimantado373 2 жыл бұрын
Give an example of what your trying to achieve first! love your site but Id like to see what your talking about before Scripting.
@itsplus5396
@itsplus5396 2 жыл бұрын
Dude it's already up there for ages an it's called scss.....
@KevinPowell
@KevinPowell 2 жыл бұрын
I have a lot of videos on SCSS too. PostCSS can do a lot that it can't (and Sass can do some things PostCSS can't do as well)
@ts8960
@ts8960 2 жыл бұрын
all that time it took to set it up , its supposed to make our lives easier not harder
@modelshipwrights
@modelshipwrights 2 жыл бұрын
I'm afraid you lost me with the installation nightmare.
@IainSimmons
@IainSimmons 2 жыл бұрын
If you think installing a few plugins and adding one additional line for each in a config file is a nightmare, you might be in the wrong business...
CSS is getting better, but Sass is still relevant
18:42
Kevin Powell
Рет қаралды 28 М.
How To Choose Ramen Date Night 🍜
00:58
Jojo Sim
Рет қаралды 53 МЛН
маленький брат прыгает в бассейн
00:15
GL Show Russian
Рет қаралды 4 МЛН
6 things I wish I knew about CSS when I started
9:09
Kevin Powell
Рет қаралды 223 М.
min(), max(), and clamp() are CSS magic!
18:12
Kevin Powell
Рет қаралды 287 М.
Learn PostCSS In 15 Minutes
14:39
Web Dev Simplified
Рет қаралды 88 М.
Flexbox or grid - How to decide?
18:51
Kevin Powell
Рет қаралды 692 М.
Probably the most underrated (and useful) CSS feature
21:11
Kevin Powell
Рет қаралды 70 М.
Creating a robust grid system using subgrid
36:22
Kevin Powell
Рет қаралды 41 М.
Two flexbox & grid behaviors most people don't know about
14:03
Kevin Powell
Рет қаралды 71 М.
min-content, max-content, fit-content - intrinsic sizing with CSS
8:52
Getting started with CSS nesting
27:14
Kevin Powell
Рет қаралды 65 М.
23 CSS features you should know (and be using) by now
31:31
Kevin Powell
Рет қаралды 52 М.