Skip to content

Use PostCSS #54

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

Closed
ai opened this issue May 14, 2015 · 9 comments · Fixed by #78
Closed

Use PostCSS #54

ai opened this issue May 14, 2015 · 9 comments · Fixed by #78

Comments

@ai
Copy link
Contributor

ai commented May 14, 2015

fastparse is awesome tool. But if you will move to PostCSS you will have these benefits:

  1. Most of source map code will be in PostCSS.
  2. You can replace url() and support @import with full CSS parsing. It is much safer. We are already have awesome plugins for url() and @import.
  3. PostCSS has “Safe Mode” to parse any legacy CSS (even broken).
  4. Right now @ben-eb creating awesome modular CSS minifier (it is much easier to fix and develop modular tool) cssnano. Right now it has better results that [clean-css] without advanced mode. So, when it became equal to clean-css, we can use it, because it is a PostCSS plugin with same source map support.

@markdalgleish what do you think as PostCSS plugin developer?

@markdalgleish
Copy link
Contributor

@ai It worked really well for me given I had zero experience beforehand.

One question I have though—does PostCSS parse selectors into an AST? I'm currently transforming selectors using regular expressions which I know isn't going to work in the long run, and it'd be much better to operate on an AST instead of a string.

@ai
Copy link
Contributor Author

ai commented May 14, 2015

@markdalgleish there is no selector parser right now and you can use css-selector-parser. @ben-eb is developing new parser, but as I know it will not be ready in this month.

@sokra
Copy link
Member

sokra commented May 14, 2015

PostCSS is nice. We previously used a full parser for the url() and imports (and now local) parsing, but using a simple string parser has the following benefits:

I'm fine with changing the css minimizer to PostCSS if it's better.

@ai
Copy link
Contributor Author

ai commented May 14, 2015

@sokra but it is not safe ;).

a {
    content: "do not use url(path)";
}

@ai
Copy link
Contributor Author

ai commented May 14, 2015

@sokra and more details for you reasonable counterarguments:

  • Of course, regexp shouldbe faster, than parser. But PostCSS is one of the fastest parsers written on JS. It is 4.5 times faster, that gonzales, that you use before.
  • PostCSS Safe Mode is a answer for future compatible. It will parse anything.
  • What is a locals? Is it relevant for postcss-local-scope?
  • We need a AST to safe change CSS.
  • It is not really simple right now. You have a lot of soure map code, which will be removed with PostCSS. PostCSS already had good postcss-url and postcss-import by @MoOx. You can use them and it will clean your code and be better for maintaining.

sokra added a commit that referenced this issue May 14, 2015
@sokra
Copy link
Member

sokra commented May 14, 2015

If you want to do a PR, feel free to do so, but I still think it not worth the work. The current parser is functional and works fine. postcss-url and postcss-import won't help here, because they do it different than the css-loader.

@MoOx
Copy link

MoOx commented May 14, 2015

The current parser is functional and works fine

Not really, there is some case where latest css syntax is causing issue (if you minify) which break the process.

@sokra
Copy link
Member

sokra commented May 15, 2015

The minimizer and the parser are separate things in the css-loader. I'm fine with replacing the minimizer with PostCSS (that not much work).

sokra added a commit that referenced this issue Jun 16, 2015
Use new CSS Modules postcss stuff

fixes #54
fixes #60
@sokra sokra mentioned this issue Jun 16, 2015
sokra added a commit that referenced this issue Jun 18, 2015
Use new CSS Modules postcss stuff

fixes #54
fixes #60
@sokra sokra closed this as completed in #78 Jun 18, 2015
@airtonix
Copy link

css-loader shouldn't do any post processing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants