Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
96 lines (84 loc) · 2.57 KB
/
Copy pathvite.config.ts
File metadata and controls
96 lines (84 loc) · 2.57 KB
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
import mdx from "@mdx-js/rollup";
import { lingui } from "@lingui/vite-plugin";
import tailwindcss from "@tailwindcss/vite";
import { tanstackRouter } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import remarkGfm from "remark-gfm";
import { defineConfig } from "vite";
import { ViteMinifyPlugin } from "vite-plugin-minify";
import mkcert from "vite-plugin-mkcert";
import { VitePWA } from "vite-plugin-pwa";
import { sri } from "vite-plugin-sri3";
import { fileURLToPath, URL } from "node:url";
import { version } from "./package.json";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
// HTTPS support in development
mkcert({
hosts: ["local.innohassle.ru"],
}),
// Enable routing via TanStack Router
tanstackRouter({
routesDirectory: "src/app/routes",
generatedRouteTree: "src/app/route-tree.gen.ts",
quoteStyle: "double",
semicolons: true,
}),
// TailwindCSS support
tailwindcss(),
// MDX support
{ enforce: "pre", ...mdx({ remarkPlugins: [remarkGfm] }) },
// React Fast Refresh, including components compiled from MDX
react({ include: /\.(mdx|js|jsx|ts|tsx)$/ }),
// Lingui catalogs (.po) + native macro transform
lingui({ macroTransform: true }),
// Offline mode via PWA
VitePWA({
registerType: "prompt",
workbox: {
globPatterns: ["**/*.{js,css,html,json,svg,png,woff2}"],
navigateFallbackDenylist: [/^\/api(?:\/|$)/, /^\/assets\//],
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5 MB
},
manifest: false, // Manifest is already in public/manifest.json
includeManifestIcons: true,
includeAssets: "*",
}),
// Minify the index.html
ViteMinifyPlugin({}),
// Subresource Integrity for built JS/CSS in index.html
sri(),
],
server: {
hmr: {
host: "local.innohassle.ru",
},
proxy: {
"/board-games-api": {
target: "http://127.0.0.1:8016",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/board-games-api/, ""),
},
},
},
resolve: {
alias: [
{
find: "@",
replacement: fileURLToPath(new URL("./src", import.meta.url)),
},
{
// Moment's locale files register on its CommonJS entry, not its ESM entry.
find: /^moment$/,
replacement: fileURLToPath(
new URL("./node_modules/moment/moment.js", import.meta.url),
),
},
],
},
define: {
// Inject the app version variable
__VERSION__: JSON.stringify(version),
},
});