Skip to content
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

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 · 17 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;
}

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

No branches or pull requests