-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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? |
Maybe this should be on the "Projects" queue? @mdo |
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. |
Just putting this here, maybe for v5.
Sass Module System
The text was updated successfully, but these errors were encountered: