0.0.6 • Published 9 months ago

@raipiot-infra/auto-import v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@raipiot-infra/auto-import

npm

raipiot infra 自动引入模块,在 Vite 项目中使用 @raipiot-infra/auto-import 预设,可以帮助我们自动引入第三方库。

安装

pnpm add -D unplugin-auto-import @raipiot-infra/auto-import

配置

Vite

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

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

Next.js

// next.config.js
const AutoImport = require('unplugin-auto-import/next').default
const { nextPresets } = require('@raipiot-infra/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
0.0.5

9 months ago

0.0.6

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.4

9 months ago

0.0.1

9 months ago