Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0 #7771

Closed
6 tasks done
grygork opened this issue Oct 18, 2024 · 31 comments
Closed
6 tasks done

Comments

@grygork
Copy link

grygork commented Oct 18, 2024

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/zf6kxq

Bug description

Zrzut ekranu 2024-10-18 o 09 12 49

Deprecation Warning on line 13, column 9 of node_modules/swiper/swiper.scss:
Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.

More info and automated migrator: https://sass-lang.com/d/import

Expected Behavior

Compatibility with Dart Sass 3.0.0.

Actual Behavior

No response

Swiper version

11.1.14

Platform/Target and Browser Versions

Dart Sass 3.0

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR

You can check PR here: #7772

@Swineherdd
Copy link

same stuff mate

@Lovely-Ruby
Copy link

how to solve it? my console has so many warning like this. i use quietDeps = true but not useful.
image

@poconri
Copy link

poconri commented Oct 21, 2024

same here

1 similar comment
@sshiling
Copy link

same here

@TimurNazarov
Copy link

Change @import to @use
https://sass-lang.com/documentation/at-rules/use/

@knakamura13
Copy link

knakamura13 commented Oct 23, 2024

Change @import to @use https://sass-lang.com/documentation/at-rules/use/

I know this comment is getting downvoted, but I found this github thread while trying to migrate from @import to @use and thought I'd share how to properly migrate it yourself:

Change this:

@import 'stylesheet.scss'

to this:

@use 'stylesheet.scss' as *;
// or `@use 'stylesheet.scss' as stylesheet;`
// which can then be used like `font-size: stylesheet.$font-size;`

@heyrian
Copy link

heyrian commented Oct 24, 2024

same here

@Maxssobolev
Copy link

Maxssobolev commented Oct 24, 2024

@knakamura13 , I changed it, but the warnings are still displayed in the console
image

Upd, works for me:
According to documentation https://vite.dev/config/shared-options.html#css-preprocessoroptions
I've installed sass-embedded package and set vite.config as

export default defineConfig({
  plugins: [react()],
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern-compiler',
      },
    },
  },
})

After that, I changed all @import "file.scss" to @use "file.scss" as *
And the warnings are gone!

@Vladislav-096
Copy link

Is it necessary to use @use instead of @import now? I added css: { preprocessorOptions: { scss: { api: 'modern-compiler', }, }, }
also to my vite.config, but i still see warning

@SirH3nry
Copy link

SirH3nry commented Oct 30, 2024

What are my options if I've got (S)CSS rules/properties in the files I want to import globally as well, and not just "variables, mixins, and functions".
Reference: vitejs/vite#12549 (comment)

@Strateg81
Copy link

Watch message in console!
"... More info: https://sass-lang.com/d/legacy-js-api" .
"... You can use the Sass migrator to automatically update your stylesheets to use the module system.

$ npm install -g sass-migrator
$ sass-migrator module --migrate-deps your-entrypoint.scss

($ sass-migrator module --migrate-deps <path/to/style.scss>)

I done it - and it works!
But at the end I'got message in console: 'Nothing to migrate!'

@Beanmommo
Copy link

Change @import to @use https://sass-lang.com/documentation/at-rules/use/

I know this comment is getting downvoted, but I found this github thread while trying to migrate from @import to @use and thought I'd share how to properly migrate it yourself:

Change this:

@import 'stylesheet.scss'

to this:

@use 'stylesheet.scss' as *;
// or `@use 'stylesheet.scss' as stylesheet;`
// which can then be used like `font-size: stylesheet.$font-size;`

After changing to @use it shows a Deprecation Warning
image

@Strateg81
Copy link

After changing to @use it shows a Deprecation Warning image

Yes, I got too! U must change your js-files.

@felixxxxxs
Copy link

While it's necessary for everyone to update their own stylesheets to use @use and @forward instead of @import, this issue is about the Swiper stylesheets still using @import.
Fixing my own stylesheets will not remove the deprecation warnings coming from the Swiper stylesheets. The Swiper stylesheets need to be updated accordingly. Or am I missing something? 🤔

@ohabash
Copy link

ohabash commented Nov 7, 2024

sass used to be the best part of my job.

@suxscribe
Copy link

So no way to use global variables now without having to import them in each and every scss component?

@skyzavr
Copy link

skyzavr commented Nov 23, 2024

I found a possible solution to this problem using sass (scss) and webpack (not sure if this is a good way to solve it):
So, I have an entry file that imports other files with common styles/variables, and I need them to be global.
So, first, we need to add a rule to webpack.config.js:

module.exports = {
 // ...
  module: {
   // ...
    rules: [
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          'css-loader',
          {
            loader: 'sass-loader',
            options: {
              additionalData: `@use 'pathToFile.scss' as *;`,
            },
          },
        ],
      },
    ],
  },
};

And in this file we need to import other files using @forward:

@forward 'pathToAnotherFile.scss';

So now we can use our variables in the app:

.header{
  color: $primary;
}

@martinille
Copy link

Downgrading sass to ~1.32.0 helped me.

@headless-kjh
Copy link

this one is helpful
@include meta.load-css("�style.scss");

@blented
Copy link

blented commented Dec 16, 2024

agree w/ @martinille , best option is to downgrade, after a bunch of digging the @use methods don't provide a viable replacement for @import

such a shame to break an entire workflow, they should just keep both options as there are pros and cons to each

@Roozenlz
Copy link

Downgrading sass to ~1.32.0 helped me.

I use ~1.77.5 helped me.

@DJHONATANFN
Copy link

VUE CLI 3, BOOTSTRAP 5.3.3 Y SASS 1.77.5 me funciona perfecto...

const { defineConfig } = require('@vue/cli-service'); module.exports = defineConfig({ transpileDependencies: true, css: { loaderOptions: { scss:{ additionalData: @import '~@/assets/scss/index.scss'; } } } });

@hiepduc24089
Copy link

try to change @import to @use but you need to reference variables with the namespace if you use variables

@fabpico
Copy link

fabpico commented Jan 6, 2025

Downgrade. npm install sass@1.79.

@IvanLudvig
Copy link

this is why web development sucks

@hammermaxmann
Copy link

SASS should be renamed SUS

@alfaniM
Copy link

alfaniM commented Feb 12, 2025

Downgrading sass to ~1.32.0 helped me.

I use ~1.77.5 helped me.

thanks, u save my life

@darckex
Copy link

darckex commented Feb 13, 2025

Dowgrading to
npm i sass@1.77.1 also removes the warning
Deprecation Warning: The legacy JS API is deprecated and will be removed in
Dart Sass 2.0.0.

@ohabash
Copy link

ohabash commented Feb 13, 2025

How long will downgrading be the official solution?

@exrhizo
Copy link

exrhizo commented Feb 16, 2025

Ran into this here: palantir/blueprint#7251

library doesn't have a long term plan, one of those things where people depend on the api in ways you don't want perhaps

I also downgraded to ~1.77.5

@MGeurts
Copy link

MGeurts commented Feb 19, 2025

I also downgraded to ~1.77.6

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests