Gadget DevelopersGD
Gadget Developersβ€’15mo agoβ€’
4 replies
Charles13

Gadget vite resolve.alias

I am trying to use vite's resolve.alias but it does not work, just want to know if I need to do additional steps to make it work on Gadget or not? I attached the folder structure I have.

Here is my vite.config.mjs
export default defineConfig({
  plugins: [gadget(), react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './api'),
    }
  },
  clearScreen: false,
});


And Inside the sample.js file I am importing a file from modules folder. These are the formats Ive tried: '@/modules/somefile.js' and '@/modules/somefile' but none of them worked so far. Do I need to do another thing before this works?

Thank you in advance πŸ™
Screenshot_from_2024-11-09_17-32-13.png
Was this page helpful?