Skip to content

SASS pre-transform error after version 8 upgrade #22433

Description

@JonathanJeune

Describe the bug

Hello guys !

First, I'm grateful for the work you're doing.
I actually have a project running on vite 7.1.12 and I want to upgrade to the 8.
When I upgrade, I have this error :

[vite] (client) Pre-transform error: [sass] Can't find stylesheet to import.
 
@use 'sass-mq' as *;
  src/assets/styles/_global.scss 1:1  @use
  src/assets/styles/index.scss 2:1    root stylesheet
  Plugin: vite:css
  File: /Users/xxx/project/src/assets/styles/index.scss:1:1
[sass] Can't find stylesheet to import.
    
   @use 'sass-mq' as *;
    ^^^^^^^^^^^^^^^^^^^
    src/assets/styles/_global.scss 1:1  @use
    src/assets/styles/index.scss 2:1    root stylesheet

Sample of a vue file :

<style lang="scss"> @use 'sass-mq' as *; @use '@/assets/styles/_functions.scss'; @use '@/assets/styles/_variables.scss'; .menu { @include mq($from: wide) { width: functions.toRem(320px); margin-left: variables.$gutters; } } </style>

The vite.config.js :

import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import commonjs from 'vite-plugin-commonjs'
import { hash } from './utils'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    commonjs()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  build: {
    commonjsOptions: { transformMixedEsModules: true },
    rollupOptions: {
      external: ['vue'],
      output: { // for cache busting
        entryFileNames: '[name]' + hash + '.js',
        chunkFileNames: '[name]' + hash + '.js',
        assetFileNames: '[name]' + hash + '.[ext]',
        globals: {
          vue: 'Vue'
        }
      }
    }
  },
  optimizeDeps: {
    exclude: ['vue-to-print']
  }
})

By the way, I tried with a new vue project (cf. the reproduction link) and I have the same error so I assume it's a vitejs issue.

Reproduction

https://github.com/JonathanJeune/vue-vite8-sass-issue-reproduction

Steps to reproduce

Run yarn install or npm install, then yarn dev or npm run dev

System Info

System:
    OS: macOS 26.3
    CPU: (8) arm64 Apple M1
    Memory: 149.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.0.0 - /Users/xxx/.nvm/versions/node/v25.0.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.6.2 - /Users/xxx/.nvm/versions/node/v25.0.0/bin/npm
  Browsers:
    Chrome: 147.0.7727.138
    Edge: 148.0.3967.54
    Firefox: 150.0
    Safari: 26.3

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions