0.0.24 • Published 11 months ago

vitejs-plugin-api-auto-import v0.0.24

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

vitejs-plugin-api-auto-import

vite 自动api导入

安装

npm i vitejs-plugin-api-auto-import

使用方法

  1. vite.config.ts
import {defineConfig} from "vite"
import AutoApi from 'vitejs-plugin-api-auto-import'
export default defineConfig({
    plugins:[
        // AutoRoute({
        //     // 全局的模块名称
        //     name:string
        //     // 编译输出的目录
        //     dir:string
        //     // 导出的变量名称
        //     constApiData:string
        //     // 输出的文件名称
        //     outFile:string
        //     // 全局注入的文件校验规则
        //     include:RegExp[]
        //     // 其他模块按需的导入
        //     resolvers?:Resolver[]
        //     导入别名
        //     resolveAliasName?:string
        //     是否动态导入别名
        //     autoResolveAliasName?:string
        //     排除的文件
        //     exclude?:string
        //     是否开启全部导出
        //     allExport?:boolean
        //     需要导出的字段,优先级最高
        //     import?:string | boolean
        // })
        AutoApi({
            name:'$apis',
            dir:'api',
            constApiData:'$apiData',
            outFile:'index.ts',
            include:[
                /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
                /\.vue$/, /\.vue\?vue/, // .vue
                /\.md$/, // .md
            ],
            resolvers:[
                {
                    from:'../data',
                    resolve(ccc){
                        return {
                            ccc,
                        }
                    }
                },
                {
                    from:'../data/index',
                    resolve({a_b_aa, asdas}){
                        return {
                            a_b_aa,
                            b:2,
                            v:{
                                asda:{
                                    as:4554,
                                    asd:['asda'],
                                    asdasdas:asdas
                                }
                            }
                        }
                    }
                }
            ],
        })
    ]
})
  1. main.ts
import App from "./App.vue"
import route from "./route"
const app = createApp(App)
.use(route)
app.mount('#app')
0.0.20

12 months ago

0.0.21

12 months ago

0.0.22

11 months ago

0.0.23

11 months ago

0.0.24

11 months ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago