unplugin-auto-import 的配置项翻译

使用过程中unplugin-auto-import顺手翻译一下,方便下次阅读

AutoImport({
  // 需要被转化的目标
  include: [
    /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
    /\.vue$/,
    /\.vue\?vue/, // .vue
    /\.md$/, // .md
  ],

  // 需要全局引入的
  imports: [
    // 预设
    'vue',
    'vue-router',
    // 自定义
    {
      '@vueuse/core': [
        // named imports
        'useMouse', // import { useMouse } from '@vueuse/core',
        // alias
        ['useFetch', 'useMyFetch'], // import { useFetch as useMyFetch } from '@vueuse/core',
      ],
      'axios': [
        // default imports
        ['default', 'axios'], // import { default as axios } from 'axios',
      ],
      '[package-name]': [
        '[import-names]',
        // alias
        ['[from]', '[alias]'],
      ],
    },
    // 引入类型
    {
      from: 'vue-router',
      imports: ['RouteLocationRaw'],
      type: true,
    },
  ],

  // 需要忽略掉的数组.
  ignore: [
    'useMouse',
    'useFetch'
  ],

  // 开启默认导出模块(export default)通过文件名自动导入
  defaultExportByFilename: false,

  // 自动导入的目录,默认只扫描一层
  dirs: [
    // './hooks',
    // './composables' // only root modules
    // './composables/**', // all nested modules
    // ...
  ],

  // 生成ts类型文件的路径.
  // 如果本地安装了 ts, 默认是 './auto-imports.d.ts' 
  // 设置成 `false` 关闭.
  dts: './auto-imports.d.ts',

  // 需要忽略自动生成声明文件的数组,当你需要提供一个自定义的函数签名时很有用
  ignoreDts: [
    'ignoredFunction',
    /^ignore_/
  ],

  // vue 模板内自动导入
  // see https://github.com/unjs/unimport/pull/15 and https://github.com/unjs/unimport/pull/72
  vueTemplate: false,

  // 自定义 resolvers, 与 `unplugin-vue-components`一致
  // see https://github.com/antfu/unplugin-auto-import/pull/23/
  resolvers: [
    /* ... */
  ],

  // 将导入注入到其他导入的末尾
  injectAtEnd: true,

  // 生成相应的 .eslintrc-auto-import.json 文件.
  // eslint globals Docs - https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals
  eslintrc: {
    enabled: false, // Default `false`
    filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
    globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  },
})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值