Emotion: Pass from option to PostCSS

Created on 27 Jul 2017  路  2Comments  路  Source: emotion-js/emotion

  • emotion version: github master
  • react version: irrelevant

What you did:

Have browserslist config in my project root.

What happened:

This config didn鈥檛 apply.

Problem description:

Here you parse CSS by PostCSS: https://github.com/tkh44/emotion/blob/89cb7956f667e71226f2bb589bbc2bb574cb38b7/src/parser.js#L39

But you didn鈥檛 pass from option to parser. As result nodes in AST don鈥檛 have origin file name.

As result, Autoprefixer didn鈥檛 load correct browserslist config.

Suggested solution:

We need to pass parser(css, { from: 'path/to/file.js' })

Most helpful comment

Also why you use styled-component/vendor/postcss-safe-parser fork? You can use standard postcss-safe-parser.

Styled Components works on client-side, this is why they care about library bundle size and fork parser to reduce size.

You parse CSS on server-side so you don鈥檛 care about parse size and could use origin parser.

If you will use origin parser, you will not need postcss-js. You can process AST by Autoprefuxer without any transformation.

Also, you can use Stylelint for this AST.

All 2 comments

Also why you use styled-component/vendor/postcss-safe-parser fork? You can use standard postcss-safe-parser.

Styled Components works on client-side, this is why they care about library bundle size and fork parser to reduce size.

You parse CSS on server-side so you don鈥檛 care about parse size and could use origin parser.

If you will use origin parser, you will not need postcss-js. You can process AST by Autoprefuxer without any transformation.

Also, you can use Stylelint for this AST.

Wow, it was fast!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitchellhamilton picture mitchellhamilton  路  82Comments

Slapbox picture Slapbox  路  24Comments

jfrolich picture jfrolich  路  29Comments

tkh44 picture tkh44  路  29Comments

lewisl9029 picture lewisl9029  路  33Comments