yuanchuan / sveltekit-autoimport

Automatically detect and import components/modules for SvelteKit projects
https://npm.im/sveltekit-autoimport
MIT License
231 stars 10 forks source link

sveltekit-autoimport is looking for svelte.config.js even when it's not needed #42

Closed anpagelian closed 3 months ago

anpagelian commented 3 months ago

Svelte configuration is inside vite.config.js. However, sveltekit-autoimport is looking for svelte.config.js

❯ bun dev
$ vite --host
Error reading svelte.config.js

  VITE v5.3.3  ready in 603 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.68.102:5173/
  ➜  press h + enter to show help

vite.config.js

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import autoImport from 'sveltekit-autoimport'
import path from 'path'

export default defineConfig({
  plugins: [
    autoImport({
      components: [
        {name: './src/components/containers', flat: true},
        {name: './src/components/displays', flat: true},
        {name: './src/components/files', flat: true},
        {name: './src/components/inputs', flat: true},
        {name: './src/views', flat: true},
        './src/components',
      ],
      module: {
        'svelte-apollo': ['mutation'],
        'svelte/transition': ['fly', 'fade'],
        svelte: ['onMount', 'setContext', 'getContext', 'createEventDispatcher']
      },
    }),
    svelte({
      onwarn(warning, defaultHandler) {
        if (warning.code.startsWith('a11y-')) return;
        // handle all other warnings normally
        defaultHandler(warning)
      }
    })
  ],
  resolve: {
    alias: {
      lib: path.resolve('./src/lib'),
      store: path.resolve('./src/store'),
      queries: path.resolve('./src/queries')
    }
  },
  base: './'
})

The problem seems indeed to be here: github.com/yuanchuan/sveltekit-autoimport/blob/…

Detected by Axnyff and posted on Stackoverflow

yuanchuan commented 3 months ago

Please try 1.8.1 with option:

autoImport({
  /* ... */
  configFile: false
})

Thanks @gengns