-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
v3 => v4 migration guide #213
Comments
Yes, and if you where using plugins it would be: serialize(compile(`${selector}{${styles}}`), middleware([...plugins, stringify])) |
What happened to the typings in v4? |
@tleunen Looks like there’s a PR for TS definitions already :) https://github.com/thysultan/stylis.js/pull/208/files |
note that there are breaking changes, such as :global() not being supported anymore. |
support for |
thank you. is usage documented somewhere? i am investigating the stylis feature set, with intent to use it via a tagged template string wrapper like csz: https://github.com/lukejacksonn/csz i am currently using the csstag library (well, i maintain a fork with a few additional features) which does just that, and relies on postcss plugins for css modules support (composes-with, @value, etc.). adding postcss-nested brings support for sass-like & unwrapping. the downside is that the postcss browser runtime is heavy. even though this is at development time only, it is clear that stylis performs much better in that department. however, the stylis feature set is minimalist compared with a full postcss pipeline, so both solutions have their respective merits. |
Nope, I don't believe it is. We'd love some contributions for the improved docs 😉 You can use it like this:
|
What happened with the plugins especially |
U can check how it can be used in our tests. |
How far I got: 3.x const Stylis = require("stylis");
const stylisRuleSheet = require("stylis-rule-sheet");
const stylis = new Stylis();
let splitRules = [];
const splitRulesPlugin = stylisRuleSheet((rule) => {
splitRules.push(rule);
});
stylis.use(disableNestingPlugin);
stylis.use(sourceMapsPlugin);
stylis.use(splitRulesPlugin);
stylis.set({
cascade: false,
compress: true,
});
...
stylis.set({
prefix:
typeof settings.vendorPrefixes === "boolean"
? settings.vendorPrefixes
: true,
});
stylis(hash, styles); 4.x const Stylis = require("stylis");
const splitRulesPlugin = Stylis.rulesheet((rule) => {
splitRules.push(rule);
});
...
const plugins = [disableNestingPlugin, sourceMapsPlugin];
if (typeof settings.vendorPrefixes !== "boolean" || settings.vendorPrefixes) {
plugins.push(Stylis.prefixer);
}
plugins.push(Stylis.namespace, Stylis.stringify, splitRulesPlugin);
Stylis.serialize(
Stylis.compile(`${hash}{${styles}}`),
Stylis.middleware(plugins)
); But this still produces different output (namely duplicate classnames e.g. Maybe someone finds this helpful. I'll be using 3.x until documentation, changelog and migration guide are added. |
This is a feature, not a bug, it has to do with maintaining neutral selector specificity. We discussed this some time back on a styled-jsx issue and added this in v4 to solve the issue they where experiencing. |
Fix: callstack#649 Stylis 4 should be safe now since emotion and styled components use it. BREAKING CHANGE: output CSS might change in some cases, see thysultan/stylis#213
Forgive me. I'm trying to upgrade and am unsure what is the equivalent middleware for the following:
(I assume |
|
For anyone who cares, what I ended up doing was:
It wasn't a 100% match in my unit-tests (removed spaces in some places; still don't know how to enable no-semicolons support). But it was close enough to the compressed CSS I wanted. |
Nice work shipping v4 🎉
Just wondering if there's a changelog or migration guide i can follow?
Looking at the README.md, i'm not entirely sure how to achieve the same functionality as i was using for v3 🤔
Is it as simple as going from:
to
The text was updated successfully, but these errors were encountered: