You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought of a way to make styled-jsx a bit more flexible and let users manipulate the CSS both at compile and run time (if they want). This for example would make it possible to use SASS with styled-jsx or I could stop supporting styled-jsx-postcss.
The babel plugin could accept an option transformCss that is a module name. Such a module exports an object with two functions for runtime and compile time. Both signatures would be (css: string) => string (by default an identity function).
const{compile: _userCompile}=require(state.opts.transformCss)// set compile to identity function if it is `undefined`// TBDconsttransformedCss=stylis(styleJsxId,_userCompile(css))// orconsttransformedCss=_userCompile(stylis(styleJsxId,css))
I am not sure about the runtime one (which for now could be postponed) but probably we would need to unshift an import like we do with _JSXStyle. The result would be:
import{runtimeas_styledJsxTransformCss}from'my-styled-jsx-transform'// ...<_JSXStyleid={1235435}css={_styledJsxTransformCss(`div { color: red }`)}/>
Fixes#182
Details available at #182 This version only works at compile time - I don't think that we should implement any runtime support right now (or ever).
I thought of a way to make styled-jsx a bit more flexible and let users manipulate the CSS both at compile and run time (if they want). This for example would make it possible to use SASS with styled-jsx or I could stop supporting styled-jsx-postcss.
The babel plugin could accept an option
transformCss
that is a module name. Such a module exports an object with two functions for runtime and compile time. Both signatures would be(css: string) => string
(by default anidentity
function).and in
.babelrc
:Which we will use as follow:
I am not sure about the runtime one (which for now could be postponed) but probably we would need to unshift an import like we do with
_JSXStyle
. The result would be:cc @rauchg @nkzawa
The text was updated successfully, but these errors were encountered: