Skip to content

Vite query?raw is ignored when an svg asset is imported via deno.json import map aliases #3893

Description

@0xMurage

Environment

  • Fresh version: @fresh/core@^2.3.3
  • Deno version: 2.9.2

Description

When importing static SVG file using a path alias defined in deno.json, Vite query ?raw is completely ignored.

Image Image

.

Imports without Deno import alias works as expected

Image

Output:
Image

Contrast behavior:

  • import icon from "../../assets/icons/plus.svg?raw" ➡️ Works (returns raw XML string).
  • import icon from "@/iassets/icons/plus.svg?raw" ➡️ Fails (returns base64 Data URL, ignoring ?raw).
  • import icon from "@/assets/icons/plus.svg?no-inline" ➡️ Works (returns asset path URL).

Current Workaround

Either:

  1. Avoid aliased imports for raw SVGs altogether and use relative paths (e.g., ../../assets/icon.svg?raw).

  2. Duplicate SVG path aliases into vite.config.ts, forcing Vite to explicitly handle the alias resolution before Deno's resolver e.g. :

import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
import { fileURLToPath, URL } from "node:url";

export default defineConfig({
  plugins: [fresh()],
  resolve: {
    alias: {
     "@/assets/icons": fileURLToPath(new URL("./assets/icons", import.meta.url)),
    },
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions