-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
vite.config.ts
116 lines (105 loc) · 3.45 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
import react from '@vitejs/plugin-react-swc';
import * as child from 'child_process';
import laravel from 'laravel-vite-plugin';
import million from 'million/compiler';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'pathe';
import { defineConfig } from 'vite';
import manifestSRI from 'vite-plugin-manifest-sri';
import packageJson from './package.json';
let branchName;
let commitHash;
try {
branchName = child.execSync('git rev-parse --abbrev-ref HEAD').toString().trimEnd();
commitHash = child.execSync('git rev-parse HEAD').toString().trimEnd();
} catch (error) {
console.error('Error executing git command:', error);
branchName = 'unknown';
commitHash = 'unknown';
}
export default defineConfig({
build: {
assetsInlineLimit: 0,
emptyOutDir: true,
// default manifest location is in .vite/manifest.json
// laravel looks in public/build/manifest.json
manifest: 'manifest.json',
outDir: 'public/build',
rollupOptions: {
input: 'resources/scripts/index.tsx',
output: {
// @ts-ignore
manualChunks(id) {
if (id.includes('node_modules')) {
// @ts-expect-error
// It won't fail lol
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
},
},
},
define: {
'import.meta.env.VITE_PYRODACTYL_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.VITE_COMMIT_HASH': JSON.stringify(commitHash),
'import.meta.env.VITE_BRANCH_NAME': JSON.stringify(branchName),
'import.meta.env.VITE_PYRODACTYL_BUILD_NUMBER': JSON.stringify(packageJson.buildNumber),
'process.env': {},
'process.platform': null,
'process.version': null,
'process.versions': null,
},
plugins: [
laravel('resources/scripts/index.tsx'),
manifestSRI(),
[
million.vite({
auto: {
threshold: 0.01,
},
telemetry: false,
}),
react({
plugins: [
[
'@swc/plugin-styled-components',
{
pure: true,
namespace: 'pyrodactyl',
},
],
],
}),
],
],
resolve: {
alias: {
'@': resolve(dirname(fileURLToPath(import.meta.url)), 'resources', 'scripts'),
'@definitions': resolve(
dirname(fileURLToPath(import.meta.url)),
'resources',
'scripts',
'api',
'definitions',
),
'@feature': resolve(
dirname(fileURLToPath(import.meta.url)),
'resources',
'scripts',
'components',
'server',
'features',
),
},
},
server: {
warmup: {
clientFiles: [
'resources/scripts/index.tsx',
'resources/scripts/routers/DashboardRouter.tsx',
'resources/scripts/components/dashboard/DashboardContainer.tsx',
'resources/scripts/routers/ServerRouter.tsx',
],
},
},
});