Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 1.28 KB

README.md

File metadata and controls

65 lines (50 loc) · 1.28 KB

@bit-ocean/auto-import

English / 简体中文

npm

Universal auto-import module.

This package provides some universal auto-import presets and resolvers for all our projects.

Installation

pnpm add -D unplugin-auto-import @bit-ocean/auto-import

Configuration

Vite

// vite.config.ts
import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import { reactPresets } from '@bit-ocean/auto-import'

export default defineConfig({
  plugins: [
    AutoImport({
      imports: reactPresets,
      dts: '@types/auto-imports.d.ts',
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.md$/ // .md
      ]
    })
  ]
})

Next.js

// next.config.js
const AutoImport = require('unplugin-auto-import/webpack').default
const { nextPresets } = require('@bit-ocean/auto-import')

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config) => {
    config.plugins.push(
      AutoImport({
        imports: nextPresets,
        dts: '@types/auto-imports.d.ts'
      })
    )
    return config
  }
}
module.exports = nextConfig

License

MIT License © 2024 Bit Ocean