Sveltekit Autoimport screenshot

Sveltekit Autoimport

Author Avatar Theme by Yuanchuan
Updated: 27 Jul 2024
236 Stars

Automatically detect and import components/modules for SvelteKit projects

Categories

Overview

The SvelteKit Auto Import tool is designed to automatically detect and import components and modules for SvelteKit projects. It searches for undefined components or modules and attempts to fix them by auto-importing. This tool requires guidance on where to import components from, how to import for specific variables, and allows for the explicit listing of components from third-party modules.

Features

  • Automatic detection and import: The tool automatically detects undefined components or modules and imports them.
  • Guided importation: Users can guide the tool on where to import components from and how to import for specific variables.
  • Explicit component listing: Users can explicitly list components being used from third-party modules.
  • Name strategy: By default, component names are namespaced with their directory names and normalized to upper camel case format.
  • Prefixing: Components can be prefixed with a given name.
  • Flat option: Users can choose to set the flat option to true, which will not add any namespace.

Installation

To install the SvelteKit Auto Import tool, follow these steps:

  1. Add the tool as a dependency in your dev environment:
npm install sveltekit-autoimport --save-dev
  1. Inside your vite.config.js file, configure the tool:
import autoimport from 'sveltekit-autoimport';

export default {
  // ...
  plugins: [
    autoimport({
      // Your configuration options here
    }),
  ],
};

Summary

The SvelteKit Auto Import tool is a helpful tool for SvelteKit projects that automatically detects and imports components and modules. It provides options for guiding the import process and allows for explicit component listing. With its easy installation process and configurable options, it simplifies the development workflow for SvelteKit projects.