aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.23k stars 44 forks source link

aliases referenced within vite.config.ts are not recognized #142

Closed basaran closed 2 weeks ago

basaran commented 2 weeks ago

Hello,

I'm not sure if this is a limitation by Vite, but given that I have this config:

    css: {
        devSourcemap: true,
        preprocessorOptions: {
            css: {},
            scss: {
                additionalData: [
                    '@import "@/scss/_vars.scss";',
                ].join("\n"), //f
            },
        },
    },

and I have this in my tsconfig.json:

  "paths": {
      "@/*": ["./src/*"],
  } //a

Vite complains that it can not locate the file. Defining the alias inside Vite resolve.alias works of course.

    resolve: {
        alias: {
            "@": path.resolve(__dirname, "src"),
        },
    },
aleclarson commented 2 weeks ago

Likely related to #30

basaran commented 2 weeks ago

Indeed it is, and the PR on upstream should fix it when it is merged as you have noted. Thank you for the insights. Closing.