Skip to content

TSConfig aliases are still unresolved for @import url(...) and @reference "..." in <style> in Astro 7 #17163

Description

@TimonLukas

Astro Info

Astro                    v7.0.0
Node                     v24.16.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

n/a

Describe the Bug

Even with the fix for #17156, Astro 7 can't resolve TS alias URLs inside <style> blocks for at least these two situations:

  • @import url("@/path/to/style.css"); causes (example):
    Error: Can't resolve '@/styles/tailwind.css' in '/REPO/temp/astro-7-tailwind-bug/src/components'
        at finishWithoutResolve (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:942:18)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1034:14
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:15:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:27:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:94:43
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:15:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
    
  • @reference "@/path/to/tailwind.css"; causes (example):
    Error: Can't resolve '@/styles/tailwind.css' in '/REPO/temp/astro-7-tailwind-bug/src/components'
        at finishWithoutResolve (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:942:18)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1034:14
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:15:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:27:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:94:43
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
        at eval (eval at create (/REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:31:10), <anonymous>:15:1)
        at /REPO/temp/astro-7-tailwind-bug/node_modules/.pnpm/[email protected]/node_modules/enhanced-resolve/lib/Resolver.js:1111:5
    

What's the expected result?

Both types of references work like they did in v6

Link to Minimal Reproducible Example

https://github.com/TimonLukas/astro-7-tailwind-bug

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix pendingReporter needs to verify the triage bot fix works

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions