-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(css): add preprocessor option to define stylus vars & funcs #7227
Conversation
Sorry I did not ran build tests. One test is failing because I chose |
Hi there, any news on the core-team discussion about this PR ? |
I was only in the first-half of the last meeting, but I don't think this has been discussed yet. It's still in the board, hopefully we'll get to it in the next one. |
We have discussed this in the last meeting! We agree that it's good to support |
playground/css/vite.config.js
Outdated
@@ -68,6 +69,10 @@ export default defineConfig({ | |||
'./options/relative-import.styl', | |||
path.join(__dirname, 'options/absolute-import.styl'), | |||
], | |||
define: { | |||
$definedColor: new stylus.Parser('#33C5FF').peek().val, |
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.
I got a type error here after merging but seems it should be an issue with my editor. cc @bluwy just in case
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.
mmm... it is a real issue 🤔
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 looks like Parser
is an internal class we shouldn't be using
//#region Internal Classes
export class Visitor {
}
export class Parser {
}
export class Evaluator {
}
export class Compiler {
}
//#endregion
Ignoring the error in the test to make this one pass for now: 556de6e
(#7227)
Description
In the light of #6354, I have done the implementation that exposes a
css.preprocessorOptions.styl.define
option that allows to define stylus variables and functions with Javascript. An other useful use-case, not discussed in the linked issue, is the possibility to define only once, in a unique place, design tokens with Javascript (such as breakpoints, colors, etc.) and use them in the Stylus side and in the Vue components, Javascript side.close: #6354
Additional context
Beware that Stylus needs to understand properly the type of nodes you define, so, for example in the case of colors, you need to define them as follows:
That’s inherent to Stylus.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).All tests pass