-
Notifications
You must be signed in to change notification settings - Fork 72
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
Migrate away from @import
#2320
Comments
@bradenmacdonald Unlikely that this Paragon issue is related to the above linked The likely reason the specific SCSS files are re-importing Paragon styles is due to Paragon's SCSS variables needing to be defined prior to using them within the file. The simplest way to do this is simply importing all of Paragon's SCSS in each individual SCSS file (current state in this MFE), however, the more correct/accepted approach to prevent duplicate Paragon CSS would be import the specific SCSS files within the SCSS entry point ( For example:
|
Yes, I tried to mention that same thing in the suggested fixes for that issue. However, that also results in larger bundle size as it results in one CSS bundle for the whole MFE, whereas if you have multiple CSS entry points (without duplication) you can sometimes get smaller initial page load times due to code splitting where some CSS and JS is loaded only when needed. However, while working on the Vite frontend shell demo I discovered there is a bigger problem with how Paragon structures its SCSS exports: namely, it doesn't provide a clear "rule-free" export of all the Paragon SCSS. For example, in that demo, the "Shell" app is already providing the Paragon SCSS so for the MFE I want its SCSS files to be able to import all the Paragon mixins, functions, variables, etc. and emit rules that build on them, but without emitting the base paragon/bootstrap rules into the build. If Paragon's SCSS was structured in a way that separates variables from rules, then the MFE could just import But what I found is that to achieve that with Paragon as it exists now, the MFE has to do something like this:
And since that's using a lot of "private" files, it kind of encourages people to just @import the whole Paragon SCSS, making that type of duplicate rules bug much easier to accidentally do. I also found that I guess that is not directly related to the issue at hand, but it's something I hope people keep in mind when working on it. |
See the "Heads up!" section here: https://sass-lang.com/documentation/at-rules/import
Paragon heavily uses
@import
, as does its consuming MFEs to import styles from other packages. SCSS recommends the use of@use
, so this issue is to track the work to migrate away from@import
in favor of@use
.The above linked docs also suggest using a migrator CLI: https://sass-lang.com/documentation/cli/migrator
The text was updated successfully, but these errors were encountered: