forked from WoWAnalyzer/WoWAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
146 lines (142 loc) · 3.98 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { join } from 'node:path';
import process from 'node:process';
import { lingui } from '@lingui/vite-plugin';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react';
import { globSync } from 'glob';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import svgr from 'vite-plugin-svgr';
const GOOGLE_ANALYTICS_SCRIPT = `
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MW95W6NHVC"></script>
<script>
var ramp = {
passiveMode: true,
que: [],
onReady: function () {
window.refreshAds();
},
};
</script>
<script
async
src="//cdn.intergient.com/1024476/73270/ramp.js"
onerror="window.adScriptFailed=true;"
></script>
<script>
window._pwGA4PageviewId = ''.concat(Date.now());
window.dataLayer = window.dataLayer || [];
window.gtag =
window.gtag ||
function () {
dataLayer.push(arguments);
};
gtag('js', new Date());
gtag('config', 'G-MW95W6NHVC', { send_page_view: false });
gtag('config', 'G-E0TKKBEXVD', { send_page_view: false });
gtag('event', 'ramp_js', { send_to: 'G-E0TKKBEXVD', pageview_id: window._pwGA4PageviewId });
</script>
</head>
`.trim();
const HASH_ONLY_CHUNKS = new Set(['StatTracker']);
// https://vitejs.dev/config/
export default defineConfig((env) => ({
build: {
cssMinify: env.mode === 'production',
sourcemap: env.mode === 'production',
rollupOptions: {
output: {
chunkFileNames: (chunkInfo) => {
if (HASH_ONLY_CHUNKS.has(chunkInfo.name)) {
return 'assets/[hash].js';
}
return 'assets/[name]-[hash].js';
},
},
},
},
plugins: [
tsconfigPaths(),
react({
babel: {
plugins: ['macros', '@emotion/babel-plugin', '@babel/plugin-syntax-import-attributes'],
},
}),
{
name: 'vite-plugin-wowanalyzer-index-html-inject-ga',
transformIndexHtml: (html) =>
process.env.VITE_ENABLE_GA === 'true'
? html.replace('</head>', GOOGLE_ANALYTICS_SCRIPT)
: html,
},
env.mode === 'test' ? null : lingui(),
svgr(),
process.env.SENTRY_AUTH_TOKEN
? sentryVitePlugin({
org: 'wowanalyzer',
project: 'wowanalyzer-app',
disable: env.mode !== 'production',
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
setCommits: {
auto: true,
},
},
sourcemaps: {
filesToDeleteAfterUpload: globSync(['./dist/**/*.map']),
},
bundleSizeOptimizations: {
excludeDebugStatements: true,
},
})
: null,
],
optimizeDeps: {
include: ['@emotion/styled/base'],
},
resolve: {
alias: {
analysis: join(__dirname, 'src', 'analysis'),
common: join(__dirname, 'src', 'common'),
game: join(__dirname, 'src', 'game'),
interface: join(__dirname, 'src', 'interface'),
localization: join(__dirname, 'src', 'localization'),
parser: join(__dirname, 'src', 'parser'),
// TEMP this fixes build errors while some retail specs are disabled
// vite-tsconfig-paths does not support the `files` option
CONTRIBUTORS: join(__dirname, 'src', 'CONTRIBUTORS'),
},
},
server: {
open: true,
port: 3000,
watch: {
ignored: ['**/.direnv/**'],
},
},
test: {
environment: 'jsdom',
restoreMocks: true,
unstubEnvs: true,
unstubGlobals: true,
globals: true,
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/cypress/**',
'**/e2e/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
],
setupFiles: ['./src/vitest.setup.ts'],
threads: true,
environmentOptions: {
jsdom: {
resources: 'usable',
},
},
resolveSnapshotPath: (testPath: string, snapExtension: string) => testPath + snapExtension,
css: false,
reporters: ['basic', 'hanging-process'],
},
}));