vite vue3 插件 扩展script标签 name inheritAttrs 等属性
npm install @ctrlc/vite-plugin-vue-setup-extend@ctrlc/vite-plugin-vue-setup-extend> 用于vue3在语法时,扩展name以及inheritAttrs属性, 用于显式声明组件展示时的名称、用于控制是否启用默认的组件attribute透传行为
``bash`
npm i @ctrlc/vite-plugin-vue-setup-extend -D
`JS`
vueScriptExtend(Options)
参数|类型|默认值|说明
----|---|-------|---
Options.include| FilterPattern | undefined | rollup过滤模式
Options.exclude| FilterPattern | undefined | rollup过滤模式
Options.hasMap| boolean | true | 是否启用 magic-string map方法 优化控制台日志
Options.hires| boolean | true | magic-string 配置参数
在vite.config.ts文件中引入插件:
`js
...
import vue from '@vitejs/plugin-vue'
import vueScriptExtend from '@ctrlc/vite-plugin-vue-setup-extend';
export default defineConfig({
plugins: [vue(), vueScriptExtend()],
})
`
`html`
hello world
编译后转义为
`js
import { defineComponent } from 'vue'
export default defineComponent({
name: "App",
inheritAttrs: false,
})
``
* 文档