Skip to content

Commit 16714e8

Browse files
committed
feat: add Naive UI resolver
1 parent c889aaf commit 16714e8

File tree

9 files changed

+613
-80
lines changed

9 files changed

+613
-80
lines changed

examples/naive-ui/components.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// generated by vite-plugin-components
2+
// read more https://github.com/vuejs/vue-next/pull/3399
3+
4+
declare module 'vue' {
5+
export interface GlobalComponents {
6+
7+
}
8+
}
9+
10+
export { }

examples/naive-ui/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Vite App</title>
7+
</head>
8+
<body>
9+
<div id="app" style="padding: 20px"></div>
10+
<script type="module" src="/src/main.ts"></script>
11+
</body>
12+
</html>

examples/naive-ui/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "fixture",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "cross-env DEBUG=vite-plugin-components:* vite",
7+
"build": "cross-env DEBUG=vite-plugin-components:* vite build"
8+
},
9+
"dependencies": {
10+
"naive-ui": "^2.11.5",
11+
"vant": "^3.0.13",
12+
"vue": "^3.0.11"
13+
},
14+
"devDependencies": {
15+
"@vitejs/plugin-vue": "^1.2.1",
16+
"@vue/compiler-sfc": "^3.0.11",
17+
"cross-env": "^7.0.3",
18+
"typescript": "^4.2.4",
19+
"vite": "^2.1.5",
20+
"vite-plugin-components": "workspace:*",
21+
"vite-plugin-md": "^0.6.3",
22+
"vite-plugin-vue-svg": "^0.1.0"
23+
}
24+
}

examples/naive-ui/src/App.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup lang="ts">
2+
import { zhCN, dateZhCN } from 'naive-ui'
3+
</script>
4+
5+
<template>
6+
<n-config-provider :locale="zhCN" :date-locale="dateZhCN">
7+
<n-space vertical>
8+
<n-input />
9+
<n-date-picker />
10+
</n-space>
11+
</n-config-provider>
12+
</template>

examples/naive-ui/src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
createApp(App).mount('#app')

examples/naive-ui/vite.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import path from 'path'
2+
import { UserConfig } from 'vite'
3+
import Vue from '@vitejs/plugin-vue'
4+
import ViteComponents, { NaiveUiResolver } from 'vite-plugin-components'
5+
6+
const config: UserConfig = {
7+
resolve: {
8+
alias: {
9+
'/~/': `${path.resolve(__dirname, 'src')}/`,
10+
},
11+
},
12+
plugins: [
13+
Vue({
14+
include: [/\.vue$/, /\.md$/],
15+
}),
16+
ViteComponents({
17+
customComponentResolvers: [
18+
NaiveUiResolver(),
19+
],
20+
globalComponentsDeclaration: true,
21+
}),
22+
],
23+
}
24+
25+
export default config

0 commit comments

Comments
 (0)