-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add support for plugins #190
Conversation
} | ||
``` | ||
|
||
In order to resolve local plugins paths you can use NodeJS' [require.resolve](https://nodejs.org/api/globals.html#globals_require_resolve). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could find a way to magically resolve paths internally.
If it is not possible then asking them to use require.resolve
or anyway provide full paths is ok I guess.
48e84f9
to
8ac17dd
Compare
### Options | ||
|
||
* `sourceMaps` generates source maps (default: `false`) | ||
* `vendorPrefix` turn on/off automatic vendor prefixing (default: `true`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a noun/plural? vendorPrefixes
(css, settings) => { /* ... */ } | ||
``` | ||
|
||
The `settings` object has the following shape: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this object could as well be renamed to options
and change shape:
{
// user options
exampleOption: true,
// babel options
babel: { // or env
sourceMaps: true,
vendorPrefix: true,
}
}
ccddb77
to
96fd965
Compare
the babel and user options: | ||
|
||
```js | ||
(css, settings) => { /* ... */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it support async operations ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it doesn't because of the sync nature of babel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw in styled-jsx-postcss I use a super hack to make async code work (syncronously) https://github.com/giuseppeg/styled-jsx-postcss/blob/master/src/babel.js#L98-L107
I wonder if we can implement the example of #5. (can you get Additionally, I wonder if there are any limitations comparing to creating a babel plugin which transforms |
We could but I'd rather keep those extensions in user space otherwise we'd have to ship styled-jsx with node-sass, postcss etc
Definitely an option but obviously writing a simple function is easier than setting up a new babel plugin that has to detect |
I'm rather wondering if you can get Can we have export default (css, props, settings) => {
if (props.type === 'text/sass') {
return compileSass(css);
} else {
return css;
}
} |
ah yes I like the idea but unfortunately we wouldn't have those info for external stylesheets :/ |
@nkzawa ideally people can annotate css eg: <style jsx>{`
/* @styled-jsx-sass */
div {
color: red;
&:hover { color: blue }
}
`}</style> and the plugin author can check for that comment export default (css, props, settings) => {
if (/@styled-jsx-sass/.test(css)) {
return compileSass(css);
} else {
return css;
}
} |
96fd965
to
dbe522a
Compare
another thing to do is figure out whether this feature could make dynamic styles (#81) harder to implement in the future |
what is the status of this pull request? |
update: we decided to wait until we implement #81 since it might affect how plugin works. |
When this gets merged I'm selling all my stuff and moving to styled-jsx island. |
Also very interested in both this and #81. Trying to decide between styled-jsx or styled-components with Next.js, and these seem to be the missing pieces. |
So, what's the status of #81? Since I really like to have these plugins available, to be able to parse PostCSS. |
It is in a good spot, in my little spare time I am trying to finish #81 basically there are a few minor adjustments to do, need to write extensive tests and docs. You can track the progress here https://github.com/zeit/styled-jsx/tree/dynamic-styles |
Hi, do we plan to merge this pull request?(and resolve conflicts) |
@Faradey27 finishing up #81 and planning on updating this PR and get it merged. With the limited amount of free time that I have it might take a few weeks 😅 but I will do my best |
Fixes #182