-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
101 lines (99 loc) · 2.84 KB
/
vite.config.ts
File metadata and controls
101 lines (99 loc) · 2.84 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
97
98
99
100
101
/// <reference types="vitest" />
import { defineConfig } from "vite";
// import react from "@vitejs/plugin-react-swc";
import react from "@vitejs/plugin-react";
import wyw from '@wyw-in-js/vite';
import { lingui } from "@lingui/vite-plugin";
import relay from "vite-plugin-relay";
import { splitVendorChunkPlugin } from "vite";
import { compression } from "vite-plugin-compression2";
import { visualizer } from "rollup-plugin-visualizer";
// https://vitejs.dev/config/
/*
// Babel based setup
export default defineConfig({
plugins: [
react({
babel: { plugins: ["relay", "macros"] },
}),
wyw(),
lingui(),
],
}); */
export default defineConfig({
base: process.env.PUBLIC_PATH ? process.env.PUBLIC_PATH : "/",
ssr: {
target: "node",
noExternal: process.env.NODE_ENV === "production" ? ["react-relay", "react-imgix", "react-google-autocomplete", "k-means-clustering-js"] : ["k-means-clustering-js"], // @NOTE: This option breaks SSR dev server
},
build: {
sourcemap: true,
manifest: true,
minify: true,
rollupOptions: {
output: {
format: "esm",
/* manualChunks: {
react: ["react", "react-dom"],
relay: ["react-relay", "relay-runtime"],
}, */
},
plugins: [visualizer({ open: false })],
},
},
test: {
environment: "jsdom", // or 'jsdom', 'node'
exclude: ["tests/e2e/**", "node_modules/**"],
setupFiles: ['test/setupTestFramework.ts'],
globals: true
},
legacy: {
proxySsrExternalModules: true
},
plugins: [
splitVendorChunkPlugin(),
react({
include: /\.(js|jsx|ts|tsx|mjs)$/,
// Config for Babel
babel: {
plugins: ["macros"]
},
// Config if SWC is used instead of babel
plugins: [
[
"@lingui/swc-plugin",
{
/* runtimeModules: {
i18n: ["@lingui/core", "i18n"],
trans: ["@lingui/react", "Trans"],
}, */
},
],
],
}),
wyw({ preprocessor: "none" }),
lingui(),
relay,
/* visualizer({
template: "treemap", // or sunburst
open: false,
gzipSize: true,
brotliSize: true,
filename: "bundle.html", // will be saved in project's root
sourcemap: false
}), */
/* Not strictly necessary as CDN deployment will compress static assets. */
/* process.env.NODE_ENV === "production"
? compression({
algorithm: "brotliCompress",
exclude: [/\.(br)$/, /\.(gz)$/],
deleteOriginalAssets: false,
})
: undefined, */
compression({ algorithm: 'gzip', exclude: [/\.(br)$/, /\.(gz)$/], deleteOriginalAssets: false }),
compression({ algorithm: 'brotliCompress', exclude: [/\.(br)$/, /\.(gz)$/], deleteOriginalAssets: false }),
],
resolve: {
// extensions: [".js", ".mjs", ".tsx", ".ts", ".jsx"],
}
});