-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why we need PostCSS if we have Webpack o_O? #861
Comments
webpack is a tool to pack all your ode into a bundles (including CSS). PostCSS is a framework to create CSS tools. webpack uses PostCSS inside (in So webpack is a pack of transforms tools (including PostCSS) to make JS/CSS/images bundles. But webpack contains only few CSS tools. Of course, you need more tools. You need Autoprefixer and here you will use PostCSS (by postcss-loader). You need to inline SVG with colors (and you will use PostCSS). You need to lint your CSS (and you will use Stylelint based on PostCSS). You may need some CSS4 polyfills (and again you will use cssnext from PostCSS). So if you want to do something with CSS, you takes PostCSS and on top of this framework you create a better tool. This is why webpack uses PostCSS too to work with CSS. |
Not sure, that I answer to all your questions :). Feel free to sub other questions. |
@ai That's what you call the PostCSS plug-in, is Webpask loaders, example: '**/*.styl': 'style!css!css-min!autoprefixer!stylys' We miss the contents of the file through a conveyor loaders:
But unlike PostCSS, webpack received files still somehow be combined intelligently, and automatically add to the generated html file. That is a standard conveyor processing of files in Webpack. In PostCSS the same, only css, but not for other types of files. Why does PostCSS need, if all he can do, Webpack can do, and even more? |
When you need to do something with CSS, you need to:
So, if you write some CSS tool, you need do have some parser to do 1, 3 and 4 steps. PostCSS is one of the best parser. Of course, webpack didn’t have anything to parse CSS. So you need PostCSS to write this webpack loaders. |
So, anyway with Second question: why you should use Right now you re-parse source on every step:
Parsing is the longest step in processors. So most time of build you spend in unnecessary parsing. If you will use |
Ooh i understand! PostCSS is a tool for creating tools for transform css code?? Oooh, PostCSS is lower than the level of Webpack, I suppose? =) That is basically a tool for building tools? |
Sure, PostCSS is low-level tool to work with CSS. This is why webpack use PostCSS inside. |
But as a bonus, PostCSS allows you to skip the file via conveyor of plugins, similar to a chain loaders Webpack? Suddenly a man have no Webpack. =) yes? PostCSS this is epic!! Why no one says what the hell this thing is doing) ?? Why everywhere it is written only that "it revolution" and "it's cool" but nowhere written that it allows you to build CSS AST and easy to work with him ??? =) |
=^_^= Yes, PostCSS could have own chain of plugins. But it is better than loaders chain in webpack. Loaders with with string input. So they need to parse file again and again. In PostCSS chain all plugins will work with already parsed CSS, so it will be much faster. |
You mean that one loader can not transfer to another loader their parsed and modified AST, and is forced to pass a string? о_О |
Yeap, they didn’t do it (technically they can, but non of your loaders do it). |
hmm, what distinguishes PostCSS, from dozens of ordinary CSS parsers? =_= convenience? and popularity? |
Sure, PostCSS is technically very close to other CSS parsers. Main difference is not so big:
|
It's phenomenal! And why some people compare it to the LESS and SASS? They think that PostCSS is a preprocessor, but not a utility for writing preprocessors? In all the articles I read today about PostCSS it is compared with the preprocessor. It's all meaningless, because it is completely different levels of abstraction. PostCSS lower level than the preprocessor. And it serves only as a UTILITY to create a preprocessor. I'm right? =) If so, I will write on the http://habrahabr.ru (popular russian site 20kk people per month) lesson on working with PostCSS. finally normal language what it is and why you need. And at the Russian community there are no normal articles about PostCSS. |
Sure. PostCSS is not a preprocessor/postprocessor but a tool to write them. |
@ai Oh, my God, you have opened my eyes. I'm going to write a lesson on working with PostCSS. Thank you, bye =) |
Sure. I think I should post this talk to Twitter, you asked good questions. |
@ai Please, get your twitter |
Hey, I appreciate your conversation. This was very instructive for me. CПАСИБО ;-) |
Все мы тут русские, просто притворяемся =) |
@uMaxmaxmaximus зато жители других стран могут прочитать 😊. Жалко, что Эсперанто не пошёл. |
@ai обратная совместимость, все дела 😊 |
Why we need PostCSS if we have Webpack o_O? Really, i not understand. PostCSS is like Webpack, but only for css files? Then why is it needed? This is not a trolling, this is a question.
The text was updated successfully, but these errors were encountered: