Describe the bug
I'm trying to use the sass pkg: importers by configuring a NodePackageImporter instance from sass-embedded in my css.preprocessorOptions but am encountering a type error:
Type 'NodePackageImporter' is not assignable to type 'NodePackageImporter | Importer<"async"> | FileImporter<"async">'.
If I use NodePackageImporter from sass instead, I get this error:
[vite:css] [sass] Error: TypeError: importer.findFileUrl is not a function
I saw this discussion reported a similar error: #17948
Reproduction
None
Steps to reproduce
My vite.config.ts configuration looks like this:
import {defineConfig} from 'vite';
import {NodePackageImporter} from 'sass-embedded';
export default defineConfig({
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
importers: [
new NodePackageImporter(),
],
},
},
},
});
The importers option seems to be typed from the sass package and not sass-embedded, so I do this to get around the type error:
import {defineConfig} from 'vite';
import {NodePackageImporter} from 'sass-embedded';
import {NodePackageImporter as DartSassPackageImporter} from 'sass';
export default defineConfig({
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
importers: [
new NodePackageImporter() as unknown as DartSassPackageImporter,
],
},
},
},
});
System Info
System:
OS: macOS 15.4.1
CPU: (14) arm64 Apple M4 Pro
Memory: 2.64 GB / 24.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 22.15.0 - ~/n/bin/node
npm: 10.9.2 - ~/n/bin/npm
pnpm: 10.9.0 - ~/n/bin/pnpm
Browsers:
Chrome: 137.0.7151.68
Safari: 18.4
npmPackages:
@vitejs/plugin-react: ^4.5.0 => 4.5.0
vite: ^6.3.5 => 6.3.5
Used Package Manager
pnpm
Logs
No response
Validations
Describe the bug
I'm trying to use the sass
pkg:importers by configuring aNodePackageImporterinstance fromsass-embeddedin mycss.preprocessorOptionsbut am encountering a type error:If I use
NodePackageImporterfromsassinstead, I get this error:I saw this discussion reported a similar error: #17948
Reproduction
None
Steps to reproduce
My
vite.config.tsconfiguration looks like this:The
importersoption seems to be typed from thesasspackage and notsass-embedded, so I do this to get around the type error:System Info
System: OS: macOS 15.4.1 CPU: (14) arm64 Apple M4 Pro Memory: 2.64 GB / 24.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 22.15.0 - ~/n/bin/node npm: 10.9.2 - ~/n/bin/npm pnpm: 10.9.0 - ~/n/bin/pnpm Browsers: Chrome: 137.0.7151.68 Safari: 18.4 npmPackages: @vitejs/plugin-react: ^4.5.0 => 4.5.0 vite: ^6.3.5 => 6.3.5Used Package Manager
pnpm
Logs
No response
Validations