feat:添加插件vite-plugin-vue-setup-extend,支持直接在setup script标签定义name

This commit is contained in:
zhangchuanlong 2022-01-25 16:26:51 +08:00
parent f744043734
commit 5a05c6ee54
4 changed files with 16 additions and 4 deletions

View File

@ -1,10 +1,11 @@
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import { unocss } from './unocss'
import { configHtmlPlugin } from './html' import { configHtmlPlugin } from './html'
import { configMockPlugin } from './mock' import { configMockPlugin } from './mock'
import { unocss } from './unocss'
export function createVitePlugins(viteEnv, isBuild) { export function createVitePlugins(viteEnv, isBuild) {
const plugins = [vue(), unocss(), configHtmlPlugin(viteEnv, isBuild)] const plugins = [vue(), VueSetupExtend(), unocss(), configHtmlPlugin(viteEnv, isBuild)]
viteEnv?.VITE_APP_USE_MOCK && plugins.push(configMockPlugin(isBuild)) viteEnv?.VITE_APP_USE_MOCK && plugins.push(configMockPlugin(isBuild))

10
package-lock.json generated
View File

@ -2839,6 +2839,16 @@
} }
} }
}, },
"vite-plugin-vue-setup-extend": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/vite-plugin-vue-setup-extend/-/vite-plugin-vue-setup-extend-0.3.0.tgz",
"integrity": "sha512-9Nd7Bj4TftB2CoOAD2ZI4cHLW5zjKMF3LNihWbrnAPx3nuGBn33tM9SVUGBVjBB6uv1mGAPavwKCTU0xAD8qhw==",
"dev": true,
"requires": {
"@vue/compiler-sfc": "^3.2.26",
"magic-string": "^0.25.7"
}
},
"vooks": { "vooks": {
"version": "0.2.10", "version": "0.2.10",
"resolved": "https://registry.npmjs.org/vooks/-/vooks-0.2.10.tgz", "resolved": "https://registry.npmjs.org/vooks/-/vooks-0.2.10.tgz",

View File

@ -41,6 +41,7 @@
"unocss": "^0.16.3", "unocss": "^0.16.3",
"vite": "^2.7.6", "vite": "^2.7.6",
"vite-plugin-html": "^2.1.1", "vite-plugin-html": "^2.1.1",
"vite-plugin-mock": "^2.9.6" "vite-plugin-mock": "^2.9.6",
"vite-plugin-vue-setup-extend": "^0.3.0"
} }
} }

View File

@ -1,4 +1,4 @@
<script setup> <script setup name="TestDialog">
import { NButton } from 'naive-ui' import { NButton } from 'naive-ui'
const handleDelete = function () { const handleDelete = function () {
$dialog.confirm({ $dialog.confirm({