tiny-vue/internals/vue-vite-import
ajaxzheng 5b922a1208
feat: Adapts to x-design specifications (#1872)
2024-08-09 14:37:01 +08:00
..
example docs(sites): optimize docs md (#1034) 2023-12-07 09:33:36 +08:00
src feat: Adapts to x-design specifications (#1872) 2024-08-09 14:37:01 +08:00
.npmignore feat(TinyVue): 同步内部代码,解决若干bug 2023-06-10 00:54:00 -07:00
README.md feat: Adapts to x-design specifications (#1872) 2024-08-09 14:37:01 +08:00
package.json feat: Adapts to x-design specifications (#1872) 2024-08-09 14:37:01 +08:00
tsconfig.json feat(TinyVue): 同步内部代码,解决若干bug 2023-06-10 00:54:00 -07:00

README.md

vite-plugin-babel-import

A TinyVue vite import plugin.

install

npm i @opentiny/vue-vite-import -D

Example

import { ButtonGroup } from '@opentiny/vue';
import { iconShare } from '@opentiny/vue-icon'

             

import ButtonGroup from '@opentiny/vue-button-group';
import iconShare from '@opentiny/vue-icon/lib/icon-share.js'

Usage

// vite.config.js

// ...
import importPlugin from '@opentiny/vue-vite-import'
// ...
export default {
  // ...
  plugins: [
    // ...
    importPlugin(
      [
        {
          libraryName: '@opentiny/vue',
          split: '-' // 自定义分隔符
        },
        {
          libraryName: '@opentiny/vue-icon',
          customName: (name) => {
            // 自定义模块名称
            return `@opentiny/vue-icon/lib/${name.replace(/^icon-/, '')}.js`
          }
        }
      ],
      'pc'
    ) // 第二个参数可选表示只打包pc或者移动模板 pc | mobile | undefined
  ]
  // ...
}

1.2.0版本新增参数重载

// vite.config.js

// ...
import importPlugin from '@opentiny/vue-vite-import'
// ...
export default {
  // ...
  plugins: [
    // ...
    importPlugin(
      {
        options: [
          {
            libraryName: '@opentiny/vue',
            split: '-' // 自定义分隔符
          },
          {
            libraryName: '@opentiny/vue-icon',
            customName: (name) => {
              // 自定义模块名称
              return `@opentiny/vue-icon/lib/${name.replace(/^icon-/, '')}.js`
            }
          }
        ],
        mode: 'pc', // mode可选表示只打包pc或者移动模板 pc | mobile | undefined
        exclude: [/test\.vue/] // 可选,表示需要剔除掉的文件
      },
      'pc'
    )
  ]
  // ...
}