Dart Sass officially deprecated @import back in version 1.80.0 (October 2024), and the Sass maintainers made it clear that Dart Sass 3.0.0 - the release that completely removes it - won't land until at least two years later. That puts the cutoff around late 2026. While you can technically shrug off the compiler warnings for now, letting your stylesheets sit unchanged until 3.0 hits is asking for a broken build.
When that update lands, Sass will just treat @import as plain CSS rather than compiling it internally. Getting ahead of this isn't a quick find-and-replace job, either; it requires rethinking how shared variables, mixins, and design tokens actually flow across your stylesheets.
Deprecation timeline:
@importhas been formally deprecated since Dart Sass 1.80.0 (October 2024).Target removal: Dart Sass 3.0.0, which won't drop before October 2026 at the earliest.
The modern tools:
@useand@forwardhave been supported since Dart Sass 1.23.0 (way back in 2019), so the migration path is already mature.Automated helper:
sass-migrator(grab it vianpm install -g sass-migratoror run it straight throughnpx).How they differ:
@useloads files into their own isolated namespace, while@forwardacts like an exporter, passing members along to other stylesheets.Bundler setups: If you're running Vite or Webpack, plan on tweaking your aliases to play nicely with the new module resolution.
If you're still on
node-sass: The deprecation warning won't show up here, but only becausenode-sasswraps the long-abandoned LibSass engine that never got module support in the first place. Migrating over to Dart Sass should be your first priority.
Why Is Sass @import Actually Being Deprecated?
The original @import rule was designed to mimic native CSS syntax, but it ended up creating a messy global scope across entire codebases. Once you imported a file, every single variable, mixin, and function declared inside it leaked into every stylesheet compiled afterward. If you ever found yourself doing a project-wide search just to figure out which mystery file declared $brand-primary, you know the pain.
Library maintainers had to invent clunky naming conventions - slapping massive prefixes onto every token - just to prevent accidental name collisions between different packages.
It took a heavy toll on build performance, too. When five independent components each imported "buttons", Sass happily recompiled those button rules five separate times, inflating your stylesheet output with duplicate CSS. On top of that, leaky global scopes have always been notorious for triggering weird, hard-to-trace bugs - like a box-shadow that silently refuses to render simply because an unexpected rule upstream hijacked the cascade.
The Real Consequence: What Happens If You Don't Migrate?
It's tempting to think that ignoring this just leaves you with annoying terminal warnings. Unfortunately, the real failure mode is much nastier. Dart Sass is transitioning to match native CSS specs, meaning the compiler will soon treat @import strictly as an in-browser directive for fetching external stylesheets over the network.
Once Dart Sass 3.0 drops support for internal Sass imports, the compiler won't bother pulling files like _variables.scss or _mixins.scss into your bundled output. Instead, it will emit a literal CSS statement right into your production bundle: @import url('_variables.scss');.
When that stylesheet loads, the browser will try to request a raw .scss file that obviously isn't sitting on your static web server, failing without a visible error. Every token, mixin, or function you were relying on instantly vanishes from runtime, leaving dependent declarations unstyled, broken, or dropped completely. Your layouts will quietly fall apart in production wherever those tokens mattered.
Most quick upgrade tutorials gloss over just how destructive this silent failure really is.
The Core Rule: When to Reach for @use vs @forward
The main hurdle when wrapping your head around the new system is figuring out which directive belongs where. The easiest trick is to think about the primary job of the file you're writing.
Use @use for Application Logic
Reach for @use whenever a stylesheet actually needs to call a variable, mixin, or function to generate CSS output. In practice, this covers nearly all of your daily component styles.
When you load a partial via @use 'colors';, Sass automatically creates a dedicated namespace matching the file name. You then pull values out using color: colors.$primary;. Everything stays neatly scoped inside that single component file, with zero chance of polluting the rest of your app.
Rely on @forward for Shared Libraries
Reach for @forward whenever you're writing an entry point or barrel file whose job is passing variables and mixins along to other files. Think of it as opening up a shared public API.
If your design system splits design tokens across a dozen separate partials, making every component import each one individually gets tedious fast. Instead, set up a central _index.scss file that forwards each token file. From there, any component that imports the index gets clean, centralized access to everything inside it.
Step-by-Step Migration and Fixing Broken Builds
Running the Automated sass-migrator
The Sass team built an official CLI tool that handles the bulk of this conversion automatically. If you run into weird version quirks when running it through npx, take a second to make sure your Node.js install is current. Run the migrator against your primary root stylesheet so it can walk the entire dependency graph:
Bash
npx sass-migrator module --migrate-deps src/styles/main.scssWhile it handles basic imports and namespaces with ease, real-world codebases with deep legacy patterns almost always require a few manual touch-ups before the build turns green again.
Troubleshooting "Declaration Order" Errors
One of the most frequent errors you'll encounter after running the automated script comes down to statement ordering. Back under @import, you could drop an import almost anywhere in the file - even nested inside an arbitrary selector block.
The modern module system strictly forbids this, throwing an explicit build error:
Plaintext
Error: @use rules must be written before any other rules.Every single @use and @forward rule must sit right at the very top of your file, before any style rules, mixins, or variable definitions appear. Whenever the automated tool can't automatically untangle a nested import, you'll need to manually hoist it to the file header and adjust your scoping accordingly.
Resolving Shared Variable Collisions
Back in the @import days, overriding a third-party theme was as simple as declaring your custom variable right before importing the library. The module system intentionally blocks that kind of implicit overriding, and it'll fail your build with a familiar error:
Plaintext
Error: This variable was not declared with !default in the @used module.To configure an imported module under the new system, you have to hand off those overrides explicitly using the with keyword. If the migrator doesn't automatically catch your custom theme values, rewrite your import like this:
SCSS
@use 'library' with (
$primary-color: #ff0000,
$border-radius: 4px
);A Modern Architecture: Structuring Design Tokens with @forward
To get the most out of the modern module system, structure your design tokens behind a single, cohesive interface. Start by setting up a dedicated tokens folder holding your raw variables: _colors.scss, _typography.scss, and _spacing.scss.
Inside that folder, drop an _index.scss file. Use @forward statements inside the index to bundle those partials together, adding clean prefixes so things stay organized when other files load them:
SCSS
// tokens/_index.scss
@forward 'colors' as color-*;
@forward 'typography' as font-*;
@forward 'spacing' as space-*;Now, your individual UI components only ever need a single @use statement to grab whatever they need. The prefixes keep the origin of every variable obvious while keeping names completely collision-free:
SCSS
// components/_button.scss
@use '../tokens';
.btn {
background-color: tokens.$color-primary;
padding: tokens.$space-medium;
}Handling Path Resolution in Bundlers
Switching away from @import can occasionally trip up path resolution in modern bundlers like Vite or Webpack. If your setup relied heavily on includePaths in your Sass loader to avoid painful ../../../styles/variables relative paths, you'll want to update that configuration.
Modern Dart Sass supports native pkg: URL resolution, but standard bundler aliases are often the cleanest way to keep your imports short. Vite handles module aliases out of the box with @use, as long as your vite.config.js maps cleanly to your style assets:
JavaScript
resolve: {
alias: {
'@styles': path.resolve(__dirname, './src/styles')
}
}With that in place, you can cleanly pull in @use '@styles/tokens'; from anywhere in your component tree without juggling brittle relative paths. Once your migration is wrapped up, drop the at-rule-disallowed-list: ['import'] rule into your Stylelint configuration so nobody accidentally sneaks a legacy @import back into the codebase.
