emotion version: github masterreact version: irrelevantWhat 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' })
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!
Most helpful comment
Also why you use
styled-component/vendor/postcss-safe-parserfork? 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.