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
If I try putting style definitions in a file whose name ends with .css.ts, like for instance styles.css.ts, Macaron does not process them, leading to a runtime error:
Error: An unexpected error occurred undefined:3069:5
Uncaught Error: Styles were unable to be assigned to a file. This is generally caused by one of the following:
- You may have created styles outside of a '.css.ts' context
- You may have incorrect configuration. See https://vanilla-extract.style/documentation/getting-started
getFileScope http://localhost:5173/node_modules/.vite/deps/@macaron-css_core.js?v=b2e50fad:3069
generateIdentifier http://localhost:5173/node_modules/.vite/deps/@macaron-css_core.js?v=b2e50fad:4658
style http://localhost:5173/node_modules/.vite/deps/@macaron-css_core.js?v=b2e50fad:4911
<anonymous> http://localhost:5173/src/styles.css.ts:2
@macaron-css_core.js:3069:11
I know this can seem counterintuitive to do so since the inherent goal of Macaron is to be able to co-locate styles with the code consuming them. But I think it doesn’t mean it should force to do so, but rather just enable.
There can still be valid use cases to group style definitions in dedicated files (in addition to having co-located styles thanks to Macaron) and to be willing to name those files with a .css.ts extension for clarity. The thing is, I don’t see why it should not be possible with Macaron.
Also, it can help for a smoother transition, since it’s much easier to globally replace @vanilla-extract/css imports with @macaron-css/core, rather than having to move the entire code into different files.
Now, one could say I could use @vanilla-extract/css directly in those files, but:
it would feel highly inconsistent, and require installing vanilla-extract and configuring it explicitly in addition to Macaron
I see why it behaves that way currently, but I think it could be changed, though by experience I understand dealing with Vite and vanilla-extract can be tricky.
I guess it would be easy to decide to process that file, but probably less to tell vanilla-extract to ignore it.
If I try putting style definitions in a file whose name ends with
.css.ts, like for instancestyles.css.ts, Macaron does not process them, leading to a runtime error:Example of file:
Why would this be a valid use case?
I know this can seem counterintuitive to do so since the inherent goal of Macaron is to be able to co-locate styles with the code consuming them. But I think it doesn’t mean it should force to do so, but rather just enable.
There can still be valid use cases to group style definitions in dedicated files (in addition to having co-located styles thanks to Macaron) and to be willing to name those files with a
.css.tsextension for clarity. The thing is, I don’t see why it should not be possible with Macaron.Also, it can help for a smoother transition, since it’s much easier to globally replace
@vanilla-extract/cssimports with@macaron-css/core, rather than having to move the entire code into different files.Now, one could say I could use
@vanilla-extract/cssdirectly in those files, but:Why it happens?
I see why it behaves that way currently, but I think it could be changed, though by experience I understand dealing with Vite and vanilla-extract can be tricky.
I guess it would be easy to decide to process that file, but probably less to tell vanilla-extract to ignore it.