DEV Community

BekmuhammadDev
BekmuhammadDev

Posted on

Viteconfig / jsconfig

Vite.config.js

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath } from "node:url";


export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: [

      {
        find: "@",
        replacement: fileURLToPath(new URL('./src', import.meta.url)),
      },
      {
        find: "@components",
        replacement: fileURLToPath(new URL('./src/components', import.meta.url)),
      },
      {
        find: "@layouts",
        replacement: fileURLToPath(new URL('./src/components/layouts', import.meta.url)),

      },
      {
        find: "@layout",
        replacement: fileURLToPath(new URL('./src/layouts', import.meta.url)),

      },
      {
        find: "@mocks",
        replacement: fileURLToPath(new URL('./src/mocks', import.meta.url)),

      },
      {
        find: "@pages",
        replacement: fileURLToPath(new URL('./src/pages', import.meta.url)),

      },
      {
        find: "@router",
        replacement: fileURLToPath(new URL('./src/router', import.meta.url)),

      },
      {
        find: "@service",
        replacement: fileURLToPath(new URL('./src/service', import.meta.url)),

      },
      {
        find: "@utils",
        replacement: fileURLToPath(new URL('./src/utils', import.meta.url)),

      },
      {
        find: "@reducer",
        replacement: fileURLToPath(new URL('./src/reducer', import.meta.url)),

      },
    ],
  },
});
Enter fullscreen mode Exit fullscreen mode

jsconfig.json

{
    "compilerOptions": {
        "paths": {
            "@/*": ["./src/*"],
            "@components/*": ["./src/components/*"],
            "@ui/*": ["./src/components/ui/*"],
            "@layouts/*": ["./src/components/layouts/*"],
            "@form/*":["./src/components/form/*"],
            "@images/*": ["./src/assets/images/*"],
            "@icons/*": ["./src/assets/icons/*"],
            "@mocks/*": ["./src/mocks/*"],
            "@utils/*": ["./src/utils/*"],
            "@layout/*": ["./src/layouts/*"],
            "@pages/*": ["./src/pages/*"],
            "@router/*": ["./src/router/*"],
            "@service/*": ["./src/service/*"],
            "@reducer/*": ["./src/components/reducer/*"],



        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)