Latest Results
Resolve tsconfig aliases in Astro style preprocessing
Fixes: #17163
Related: 3cf76c035eef5954637e78015be9c20d0129599a, 4766f3716d1e8ee47902bfdf87963a215c462cbe
Goal: restore Astro 6-style tsconfig alias handling for CSS references that are written inside .astro <style> blocks and therefore go through Astro's direct preprocessCSS() path instead of Vite's normal transform pipeline.
Issue #17163 reported that the earlier CSS alias repair still missed @import url("@/...") and Tailwind-style @reference declarations in component styles. The issue discussion later added @config. Testing resolve.tsconfigPaths showed it is not a replacement here: with Vite 8.1.0/Rolldown 1.1.2 it fails existing Astro alias tests on its own, and even when combined with Astro's custom alias plugin it does not fix the <style> preprocessCSS() path.
Decision: keep Astro's existing config alias plugin, extract its CSS alias rewriting into resolveCssAliases(), and call that same helper from createStylePreprocessor before preprocessCSS(). This preserves the standalone .css transform behavior while covering the compiler preprocessing path that previously bypassed the transform hook.
The helper now matches @import, @reference, and @config path-bearing at-rules, plus the existing quoted url() handling. It resolves only aliases that map to existing files, matching the previous best-effort behavior.
Testing: added an alias-path-alias-style fixture page with @import url('@/styles/base.css'), @reference '@/styles/reference.css', and @config '@/tailwind.config.ts' inside a component <style>. The test asserts the imported CSS is bundled and no @/ alias remains in output CSS.
Verification run:
- pnpm -C packages/astro run build:ci
- pnpm -C packages/astro exec tsc -b
- pnpm -C packages/astro exec astro-scripts test "test/{alias-tsconfig,alias-tsconfig-no-baseurl,alias-path-alias-style,alias-css-url}.test.ts"
- pnpm formatstyle-import-alias-resolution Latest Branches
-24%
style-import-alias-resolution 0%
0%
cevdetta:feature/change-charset-declaration-fully-lowercase © 2026 CodSpeed Technology