-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite.config.mts
More file actions
121 lines (119 loc) · 3.85 KB
/
vite.config.mts
File metadata and controls
121 lines (119 loc) · 3.85 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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({
// @swc/core 1.15.8 introduced a regression where it panics instead of silently discarding
// missing source maps referenced by //# sourceMappingURL= comments in dependencies.
// Remove this once a @swc/core release restores the documented "silently discarded" behavior.
useAtYourOwnRisk_mutateSwcOptions: (options) => {
options.inputSourceMap = false;
},
}),
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/UploadHttpLink.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'],
},
},
},
},
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
preprocessorOptions: {
scss: {
// can't get import to work until Bootstrap supports it
silenceDeprecations: ['import', 'legacy-js-api'],
quietDeps: true,
},
},
},
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'),
},
},
});