Skip to content

Commit

Permalink
feat: add Naive UI resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 11, 2021
1 parent c889aaf commit 16714e8
Show file tree
Hide file tree
Showing 9 changed files with 613 additions and 80 deletions.
10 changes: 10 additions & 0 deletions examples/naive-ui/components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// generated by vite-plugin-components
// read more https://github.com/vuejs/vue-next/pull/3399

declare module 'vue' {
export interface GlobalComponents {

}
}

export { }
12 changes: 12 additions & 0 deletions examples/naive-ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app" style="padding: 20px"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions examples/naive-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "fixture",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "cross-env DEBUG=vite-plugin-components:* vite",
"build": "cross-env DEBUG=vite-plugin-components:* vite build"
},
"dependencies": {
"naive-ui": "^2.11.5",
"vant": "^3.0.13",
"vue": "^3.0.11"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.2.1",
"@vue/compiler-sfc": "^3.0.11",
"cross-env": "^7.0.3",
"typescript": "^4.2.4",
"vite": "^2.1.5",
"vite-plugin-components": "workspace:*",
"vite-plugin-md": "^0.6.3",
"vite-plugin-vue-svg": "^0.1.0"
}
}
12 changes: 12 additions & 0 deletions examples/naive-ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script setup lang="ts">
import { zhCN, dateZhCN } from 'naive-ui'
</script>

<template>
<n-config-provider :locale="zhCN" :date-locale="dateZhCN">
<n-space vertical>
<n-input />
<n-date-picker />
</n-space>
</n-config-provider>
</template>
4 changes: 4 additions & 0 deletions examples/naive-ui/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')
25 changes: 25 additions & 0 deletions examples/naive-ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import path from 'path'
import { UserConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import ViteComponents, { NaiveUiResolver } from 'vite-plugin-components'

const config: UserConfig = {
resolve: {
alias: {
'/~/': `${path.resolve(__dirname, 'src')}/`,
},
},
plugins: [
Vue({
include: [/\.vue$/, /\.md$/],
}),
ViteComponents({
customComponentResolvers: [
NaiveUiResolver(),
],
globalComponentsDeclaration: true,
}),
],
}

export default config
Loading

0 comments on commit 16714e8

Please sign in to comment.