MaiaM
Denoβ€’4mo ago
Maia

Failing to create import alias for tauri project

Hello everyone. I created a tauri project recently with deno and one of the things I'm trying to setup are aliases so I don't have to use relative imports within my vue files.
As per docs, I created a deno.json file in the project's root:
{
  "$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json",
  "imports": {
    "@/": "./src/"
  }
}

Where my project looks like:
/
/src
/src/layouts/default.vue
/src/components/AppBar.vue

My default layout looks like so:
<template>
  <v-app>
    <AppBar></AppBar>

    <v-main>
      <router-view />
    </v-main>
  </v-app>
</template>

<script lang="ts" setup>
import AppBar from "../components/AppBar.vue"; // works
// import AppBar from "@/components/AppBar.vue";  // fails
</script>

The error is:
[plugin:vite:import-analysis] Failed to resolve import "@/components/AppBar.vue" from "src/layouts/default.vue". Does the file exist?

Not entirely sure what am I missing here. Ideas?
Was this page helpful?