feat(css): add preprocessor option to define stylus vars & funcs#7227
feat(css): add preprocessor option to define stylus vars & funcs#7227patak-cat merged 7 commits intovitejs:mainfrom
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
| path.join(__dirname, 'options/absolute-import.styl'), | ||
| ], | ||
| define: { | ||
| $definedColor: new stylus.Parser('#33C5FF').peek().val, |
There was a problem hiding this comment.
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.
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.defineoption 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