-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
126 lines (122 loc) · 3.5 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/// <reference types="vitest" />
import { fileURLToPath, URL } from "node:url";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import dns from "dns";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { VueRouterAutoImports } from "unplugin-vue-router";
import VueRouter from "unplugin-vue-router/vite";
import { defineConfig, loadEnv } from "vite";
import Layouts from "vite-plugin-vue-layouts";
import generateSitemap from "vite-ssg-sitemap";
import svgLoader from "vite-svg-loader"; // https://github.com/jpkleemans/vite-svg-loader
import { configDefaults } from "vitest/config";
dns.setDefaultResultOrder("verbatim");
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const DEV_PORT = parseInt(env.VITE_PORT || "5173");
return {
plugins: [
VueRouter({
dts: "./types/typed-router.d.ts",
}),
vue({
script: {
defineModel: true,
propsDestructure: true,
},
}),
vueJsx(), // More examples: https://github.com/vitejs/vite-plugin-vue/tree/main/playground/vue-jsx
svgLoader({
svgoConfig: {
// https://github.com/svg/svgo#built-in-plugins
plugins: ["preset-default", "removeDimensions"],
},
}),
AutoImport({
imports: [
"vue",
"pinia",
"@vueuse/head",
VueRouterAutoImports,
{
"vue-router/auto": ["useLink"],
},
],
dirs: ["src/composables", "src/utils", "src/helpers", "src/stores"],
dts: "./types/auto-imports.d.ts",
eslintrc: {
enabled: true,
filepath: "./types/.eslintrc-auto-import.json",
},
}),
Components({
extensions: ["vue", "tsx", "md"],
dts: "./types/components.d.ts",
globalNamespaces: ["shared"],
directoryAsNamespace: true,
collapseSamePrefixes: true,
deep: true,
types: [],
}),
Layouts(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
appconfig: fileURLToPath(new URL("./appconfig.mjs", import.meta.url)),
},
},
build: {
commonjsOptions: {
include: ["appconfig.mjs", "node_modules/**"],
},
},
optimizeDeps: {
include: ["appconfig"],
},
server: {
port: DEV_PORT,
},
ssgOptions: {
script: "async",
formatting: "minify",
// https://github.com/GoogleChromeLabs/critters#critters-1
crittersOptions: {
pruneSource: true,
},
onFinished() {
generateSitemap();
},
},
test: {
environment: "jsdom",
exclude: [...configDefaults.exclude, "e2e/*"],
root: fileURLToPath(new URL("./", import.meta.url)),
setupFiles: ["vitest.setup.ts"],
dir: "src",
reporters: ["default", "html"],
outputFile: {
html: "./test-results/unit/html/index.html",
},
transformMode: {
web: [/\.[jt]sx$/], // To make it work with defineComponent and tsx
},
coverage: {
all: false,
include: [
"src/components/**",
"src/composables/**",
"src/utils/**",
"src/helpers/**",
// Exclude
"!src/components/example",
],
reporter: ["text", "json-summary"],
reportsDirectory: "./test-results/unit",
},
},
};
});