English / 简体中文
Universal auto-import module.
This package provides some universal auto-import presets and resolvers for all our projects.
pnpm add -D unplugin-auto-import @bit-ocean/auto-import
// 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.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
MIT License © 2024 Bit Ocean