Skip to content

[sass] Error: The importer must return an absolute URL, was "[object Promise]" #1885

@diegovilar

Description

@diegovilar

Please provide the environment you discovered this bug in.

Reproduction: https://github.com/diegovilar/analog-scss-issue

Which area/package is the issue in?

vite-plugin-angular

Description

It seems like vite-plugin-angular doesn't work correctly with SCSS when it comes to using @use, @import and @forward. It seems to be mixing sync and async APIs from both sass and sass-embedded (tried both). This works as expected with a pure vite setup, but not when using the analog plugin.

Reproduction repo: https://github.com/diegovilar/analog-scss-issue

Steps do reproduce:

  1. Create a new project with pnpm create [email protected] - 49732e7
  2. Switch the setup from CSS to SCSS and try to @use another SCSS file - 15a5c14
  3. Serve and open the app to see the error

Please provide the exception or error you saw

[plugin:vite:css] [sass] Error: The importer must return an absolute URL, was "[object Promise]"
  ╷
1 │ @use "./styles/global" as *;
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  /home/dev/workspace/analog-project/src/styles.scss 1:1  root stylesheet

at handleCompileResponse (/home/dev/workspace/analog-project/node_modules/.pnpm/[email protected]/node_modules/sass-embedded/dist/lib/src/compiler/utils.js:155:15)
    at AsyncCompiler.compileRequestAsync (/home/dev/workspace/analog-project/node_modules/.pnpm/[email protected]/node_modules/sass-embedded/dist/lib/src/compiler/async.js:100:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Object.run (file:///home/dev/workspace/analog-project/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:32546:19)
    at async process (file:///home/dev/workspace/analog-project/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:32574:20)
    at async compileCSSPreprocessors (file:///home/dev/workspace/analog-project/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:32009:27)
    at async compileCSS (file:///home/dev/workspace/analog-project/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:32037:30)
    at async TransformPluginContext.handler (file:///home/dev/workspace/analog-project/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:31579:54)

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions