tiny-vue_version0/internals/vue-vite-import
Leon2nd e3924732b7 Initial commit 2024-09-10 16:44:27 +08:00
..
example Initial commit 2024-09-10 16:44:27 +08:00
src Initial commit 2024-09-10 16:44:27 +08:00
.npmignore Initial commit 2024-09-10 16:44:27 +08:00
README.md Initial commit 2024-09-10 16:44:27 +08:00
package.json Initial commit 2024-09-10 16:44:27 +08:00
tsconfig.json Initial commit 2024-09-10 16:44:27 +08: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
  ]
  // ...
}