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
|
/* eslint-disable no-process-env */
/* eslint-env node */
import { builtinModules } from 'node:module';
import path from 'node:path';
import react from '@vitejs/plugin-react';
import { banner, chrome } from '../../config/buildConstants.js';
import fileUrlToDirname from '../../config/fileUrlToDirname.js';
const thisDir = fileUrlToDirname(import.meta.url);
const mode = process.env.MODE || 'development';
const isDevelopment = mode === 'development';
/**
* @type {import('vite').UserConfig}
* @see https://vitejs.dev/config/
*/
export default {
/** @type {import('vite').LogLevel} */
logLevel: 'info',
mode,
root: thisDir,
cacheDir: path.join(thisDir, '../../.vite'),
plugins: [
react({
babel: {
// Gets rid of deoptimization warnings for large chunks.
// We don't need to minify here, because the output of babel
// will get passed to esbuild anyways.
compact: false,
minified: false,
},
}),
],
base: '',
optimizeDeps: {
exclude: ['@sophie/shared'],
},
define: {
__DEV__: JSON.stringify(isDevelopment), // For mobx
},
build: {
target: chrome,
assetsDir: '.',
outDir: 'dist',
emptyOutDir: true,
sourcemap: isDevelopment,
minify: !isDevelopment,
brotliSize: false,
rollupOptions: {
external: ['mst-middlewares', 'remotedev', ...builtinModules],
output: {
banner,
},
},
},
};
|