-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Switch from Sass imports to Sass Module System #29853
Comments
AFAICT, the module system only works in Dart Sass, not in ruby Sass or Lib Sass. Since the majority of build systems won't support this yet, I guess it won't be a good idea to switch now. |
What are the 'majority of build systems' you mention? Maybe the right approach would be to migrate from node-sass to sass first. That might clear these warning from my build logs as another added bonus:
|
@mocsy, Other than that, we have a list of other compilers using LibSass: https://sass-lang.com/libsass Even if we switch to |
LibSass: sass/libsass#2807 |
Just hopping in here to +1 this, especially since SASS used Bootstrap as an example for how the new package system could be used. |
The event horizon for node-sass supporting the new module system seems like 2-3+ years, it's already many months behind libsass which seems like it's slating impl for a major release tentatively in 2021? I'd love to see Sass modules used in bootstrap, but it does seem like there needs be either a cultural shift from using libsass or an influx of new contributors to help speed up implementation. Seems like web-devs wanting to do c++ development is a fairly niche subset! |
Why not leave 4.5 as libsass compatible, and make 5 dartsass...at least until libsass updates itself (if ever). Backwards compatibility makes no sense here. |
I really need this +1 |
Highly need this for more advanced theming support |
https://github.com/sass/sass/blob/master/accepted/module-system.md#timeline - |
Current (September 2020) monthly On the other hand, if we stick to |
SASS language has one specification it's not depend on if it is libsass, ruby sass or dart sass. It can be deprected in 2021 for dart sass and e.g. in 2022 for another implementation if it will be existing (I mean As an option it can be like it was done for SCSS and LESS - two folders with SCSS with "import" directives and another folder with new "use" directive. As a first step maybe use migration tools and try to do it automatically: https://sass-lang.com/blog/the-module-system-is-launched#automatic-migration |
I wouldn't make decision based on statistics, becuase mostly sass implementation and version is selected by frameworks. When frameworks will remove node-sass and add dart sass this statistics will be changed very quickly. E.g. Angular already switched to dart sass from node-sass in Angular 8 |
Aside from wanting to move away from imports, more importantly the Sass team is in the process of deprecating "LibSass and the packages built on top of it, including Node Sass". Their project to do so is here with issues discussing the move linked in it (the source of my quote). I think it would be a smart move to swap out According to the The most recent issue I could find on precision is here, and a quick test of setting the width of an element in Chrome (on Windows Server 2019) to 599.99999px or 600.00001px both show 600px in the dev tools box model diagram, as @MartijnCuppens was testing in the issue, so hopefully that concern is also no longer an issue. |
We already test dart-sass on CI https://github.com/twbs/bootstrap/blob/main/.github/workflows/dart-sass.yml They use a fixed 10 digit precision which might be too much. For the minified files, we can bring it down to 6 or whatever, but for the normal files, it will be 10. That being said, that's not a real issue TBH. The real issue is how we are going to catch breakage. I guess we could just test node-sass on CI and switch to sass. That's doable. |
@XhmikosR since the node-sass is officially deprecated ( https://github.com/sass/node-sass#node-sass ) could the team move forward with this one? |
Hey @ffoodd Soon in October 2022 the Do you think you could switch from Maybe switching to Many thanks! |
The plan is to migrate in v6, we won't release two versions like that at the same time :). It is a breaking change and we can't do it until then. |
Sass lead designer here! We've tried to design the module system to that it's possible to migrate a library to it without making that a breaking change, using import-only files with forwards to continue to expose the same APIs to existing The only really necessary breaking change is dropping support for Node Sass, but it's been deprecated for almost two years now. |
@nex3
_bootstrap.import.scss has the following content which forwards the file in the same directory: @forward "bootstrap" as bs-*; _bootstrap.scss has the following content which should override bootstrap !default variables and import the original library like mentioned here: https://sass-lang.com/documentation/at-rules/import#configuring-modules-through-imports // prefixed like forwarded in the import file
$bs-container-max-widths: (
md: 750px,
lg: 992px,
xl: 1000px,
);
$bs-container-padding-x: 15px;
@import "../../../assets/bootstrap5/bootstrap"; The question is how do I use bootstrap mixins now inside my core directory where I define my own styles. I tried it this way but without any results. @use "../vendors/bootstrap/bootstrap" as bs;
h1 {
font-size: 1.4rem;
@include bs.media-breakpoint-up(md) {
font-size: 3rem;
}
} Edit: solved it by modifying my style.scss as following and accessing mixins like described above. @charset "UTF-8";
@forward "vendors/bootstrap/bootstrap";
@forward "core"; Extending bootstrap classes: unfortunately stylelint doesn't like it when you extend classes directly, instead you should use %placeholders (stylelint rule) which are regular class defintions but doesn't render in the final .css. Here it's different since we want those bootstrap classes to have available in our final .css. @use "../vendors/bootstrap/bootstrap" as bs; // doesn't require a namespace
h1 {
@extend .fs-1;
} |
Hi all, I'm a bit confused. From everything I've seen, Secondly, if this is true how can our apps utilizing the both bootstrap and sass packages? Wouldn't we be dead in the water? |
@Eireternal the latest update on the
Found this at the bottom of https://sass-lang.com/blog/the-module-system-is-launched |
@import being deprecated or not, Dart SASS has all the new features. The SASS team made it quite clear that only the Dart version will be enhanced over time. In my own experience switching to Dart SASS from other versions was painless. I hope so that it has been the case for others. So making Dart SASS a requirement for Bootstrap v6 is IMHO sensible. |
Is there any sort of update on this? Sass is moving forward on deprecating @import. sass/sass#3513 |
For now, we'll try to stick to the original plan: in v6
Depending on when the deprecation of imports is released in Sass, we'll maybe introduce modules sooner in an intermediate v5.X if necessary, but it's more of a backup plan for now IMO |
Global functions are now located inside built-in Sass modules. But this is not supported largely yet: Bootstrap: plans to support from version 6: twbs/bootstrap#29853 Scssphp: plans to support in version 2.x: scssphp/scssphp#647 Also see: https://github.com/sass/sass/blob/main/accepted/module-system.md#timeline https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/no-global-function-names/README.md
A first step could be to enable dart-sass in Hugo, because by default it use lib-sass. |
5 years later, the hammer hits; and, it's still not upgraded? At the very least, can we get a v6 label (so it shows up on search)? Already had to wait for ng-bootstrap and Angular 19, now this? At what point do I give up on bootstrap?
|
When following the customization guide on the website, numerous sass deprecation warnings are thrown about this:
|
Since I just tried removing all @import usage on the sites i work on. I would like to add to the discussion something TWBs will need to consider if they haven't already, as well as give some clarity to those asking why it's take so long for TWB to migrate. The biggest issue I ran into is the fact that the new Module pattern only lets you configure the variables once, using either @forward with() or @use with(), and this must happen before before any plain @use imports are used if the variables are shared in another module. This the equivalent limitation of @import in that you had set the variables you wanted to customize before you @imported the file you wanted to customize. This particular problem though is made worse due to the current structure of the sass Variables in bootstrap, that heavily rely on reusing sass variables to set other related sass variables or (even css variables) (e.g. the two biggest being $utilities, $theme_colors, etc) and it's reliance on these shared variables in modules like _functions.scss. This ends up creating a Chicken and Egg Problem if you want to use a boostrap function in _functions.scss to override defaults like $success, $primary, etc and then have their customized values used by the sass variables $theme-colors, and/or $utilities. In the new @use model and bootstrap's current variable structure you are forced to manually update $theme-colors and/or $utilities with map.merge after you customize a bootstrap sass variable, which due to the shear amount of sass variable reuse in Utilities is prone to miss errors due to shear size of the $utilities variable. not only that you would have to also manually update all the sass variables that also consume the sass variable you customized. This can be worked around to some extent with the older @import model because the amount of global variables required for _functions.scss to work correctly was minimal, which allowed you to use those functions in your customized bootstrap variables before you imported _variables.scss. It is due to this chick and egg problem I'm not able to remove @import usage for twbs in my sites but have been able to remove its usage in all my other use cases (was able to remove ~1000 @imports and is now left with only 6 @imports for twbs, as it was needed to work around the issue described above until I have time to refactor my code to remove the issue described above). |
(Worth noting that the Sass team has been working directly with the Bootstrap team to do this migration, but personal lives and holidays have made progress slow recently.) |
Hey there, Several issues have been opened in our repository related to recent Sass deprecation warnings, as well as the transition from Sass imports to the Sass module system, such as this one. Except if I'm wrong, these issues are interconnected: addressing the deprecation warnings requires using and adopting the Sass module system, which involves refactoring the code and updating the Hugo configuration to fully support Dart Sass. I’ve started working on it in this pull request, though it’s still in a very early draft stage. Apologies for the delay—I’ve been away for about a month due to personal matters and holidays. I’ll pick this back up as soon as I can. I know the wait can be frustrating, and I appreciate your patience. |
Just putting this here, maybe for v5.
Sass Module System
The text was updated successfully, but these errors were encountered: