#3893·fresh

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

Author: 0xMurageCreated Jul 22, 2026Updated Jul 22, 2026

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.

ImageImage

.

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. :

javascript
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)),
    },
  },
});