-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
109 lines (97 loc) · 2.78 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { defineConfig } from "vite";
import * as path from "path";
import Components from "unplugin-vue-components/vite";
import { PrimeVueResolver } from "unplugin-vue-components/resolvers";
import AutoImport from "unplugin-auto-import/vite";
import Layouts from "vite-plugin-vue-layouts";
import Pages from "vite-plugin-pages";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
base: "./",
server: {
hmr: {
port: false,
path: "/ws",
},
},
// https://github.com/antfu/vite-ssg
ssgOptions: {
script: "async",
formatting: "minify",
},
optimizeDeps: {
include: ["vue", "vue-router", "@vueuse/core"],
exclude: ['* > vue-demi'],
},
plugins: [
vue({
include: [/\.vue$/, /\.md$/],
template: {
compilerOptions: {
directiveTransforms: {
styleclass: () => ({
props: [],
needRuntime: true,
}),
ripple: () => ({
props: [],
needRuntime: true,
}),
},
},
},
}),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: ["vue", "vue-router", "vue-i18n", "@vueuse/head"],
exclude: ["**/dist/**"],
dts: "src/auto-import.d.ts",
}),
Components({
// relative paths to the directory to search for components.
dirs: ["src/components"],
// valid file extensions for components.
extensions: ["vue"],
// search for subdirectories
deep: true,
// resolvers for custom components
resolvers: [PrimeVueResolver()],
// generate `components.d.ts` global declarations,
// also accepts a path for custom filename
// default: `true` if package typescript is installed
dts: "src/components.d.ts",
// Allow subdirectories as namespace prefix for components.
directoryAsNamespace: false,
// Vue version of project. It will detect automatically if not specified.
// Acceptable value: 2 | 2.7 | 3
version: 3,
}),
Layouts(),
Pages({
dirs: [
{ dir: "src/pages", baseRoute: "" },
// { dir: "src/features/**/pages", baseRoute: "features" },
// { dir: "src/admin/pages", baseRoute: "admin" },
],
extendRoute(route, parent) {
if (route.path === "/") {
// Index is unauthenticated.
return route;
}
// Augment the route with meta that indicates that the route requires authentication.
return {
...route,
meta: { auth: true },
};
},
exclude: ["**/components/*.vue"],
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"~": path.resolve(__dirname, "node_modules/"),
},
},
});