babel-plugin-styled-components icon indicating copy to clipboard operation
babel-plugin-styled-components copied to clipboard

CSS passed to createGlobalStyle isn't minified

Open triallax opened this issue 6 years ago • 3 comments

triallax avatar Oct 04 '19 15:10 triallax

Same here. Comments aren't removed either.

Maybe a missing isPureHelper import in https://github.com/styled-components/babel-plugin-styled-components/blob/ad289a02bb22fd885dcea8f55835d99cb9346be8/src/visitors/minify.js ?

Or missing export isCreateGlobalStyleHelper with isHelper in https://github.com/styled-components/babel-plugin-styled-components/blob/ad289a02bb22fd885dcea8f55835d99cb9346be8/src/utils/detectors.js ?

lewislbr avatar Oct 25 '19 09:10 lewislbr

I have a simple but kinda verbose and ugly workaround. Change:

createGlobalStyle`/* Your css here */`

to:

createGlobalStyle`${css`/* Your css here */`}`

triallax avatar Oct 27 '19 10:10 triallax

What's interesting is that tests for this case exists, and they pass for some reason 🤔 https://github.com/styled-components/babel-plugin-styled-components/tree/main/test/fixtures/minify-css-in-helpers

wojtekmaj avatar Jul 08 '21 06:07 wojtekmaj