-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.mts
98 lines (96 loc) · 3.19 KB
/
vite.config.mts
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tsconfigPaths from 'vite-tsconfig-paths';
import { fileURLToPath } from 'url';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { globalDefines } from './globalDefines.mts';
export function absolutePath(relativePath: string) {
return fileURLToPath(new URL(relativePath, import.meta.url));
}
export default defineConfig({
plugins: [react(), tsconfigPaths(), nodePolyfills()],
resolve: {
mainFields: ['module'],
},
define: globalDefines,
experimental: {
renderBuiltUrl: (filename, { hostType }) => {
if (hostType !== 'js' || filename === 'setPublicPath.ts') {
return { relative: true };
} else {
return { runtime: `window.__intercodeAssetURL(${JSON.stringify(filename)})` };
}
},
},
build: {
copyPublicDir: false,
rollupOptions: {
// tree shaking is causing empty GraphQL document constants as of Rollup 4.27,
// hopefully can remove this eventually
treeshake: false,
input: {
application: absolutePath('./app/javascript/packs/applicationEntry.ts'),
'application-styles': absolutePath('./app/javascript/packs/applicationStyles.ts'),
...(process.env.NODE_ENV === 'production'
? {}
: {
'dev-mode-graphiql': absolutePath('./app/javascript/DevModeGraphiql.tsx'),
}),
},
output: {
dir: absolutePath('./public/packs'),
entryFileNames: '[name].js',
manualChunks: {
apollo: ['@apollo/client', 'apollo-upload-client/createUploadLink.mjs'],
codemirror: [
'@codemirror/state',
'@codemirror/view',
'@codemirror/language',
'@codemirror/lang-html',
'@codemirror/lang-json',
'@codemirror/lang-markdown',
'@lezer/common',
],
currencyCodes: ['@breezehr/currency-codes'],
graphql: ['graphql'],
i18next: ['i18next', 'react-i18next'],
lodash: ['lodash'],
luxon: ['luxon'],
reactRouter: ['react-router', 'react-router-dom'],
},
},
},
},
server: {
port: 3135,
host: '0.0.0.0',
origin: 'https://assets.intercode.test:3135',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
https: {
key: absolutePath('./dev_certificate.key'),
cert: absolutePath('./dev_certificate.crt'),
ca: absolutePath('./dev_ca.crt'),
},
warmup: {
clientFiles: [absolutePath('./app/javascript/packs/applicationEntry.ts')],
},
},
preview: {
port: 3135,
host: '0.0.0.0',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
https: {
key: absolutePath('./dev_certificate.key'),
cert: absolutePath('./dev_certificate.crt'),
ca: absolutePath('./dev_ca.crt'),
},
},
});