-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
87 lines (85 loc) · 2.31 KB
/
vite.config.js
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
const { defineConfig } = require('vite');
const react = require('@vitejs/plugin-react');
const path = require('path');
const fs = require('fs');
const mkcert = require('vite-plugin-mkcert');
// https://vitejs.dev/config/
module.exports = ({ command, mode }) => {
const scalaClassesDir = path.resolve(__dirname, 'web/target/scala-3.1.3');
const isProduction = mode == 'production';
const sjs = isProduction
? path.resolve(scalaClassesDir, 'web-opt')
: path.resolve(scalaClassesDir, 'web-fastopt');
const common = path.resolve(__dirname, 'common/');
const webappCommon = path.resolve(common, 'src/main/webapp/');
const imagesCommon = path.resolve(webappCommon, 'images');
const publicDirProd = path.resolve(common, 'src/main/public');
const publicDirDev = path.resolve(common, 'src/main/publicdev');
const publicDir = mode == 'production' ? publicDirProd : publicDirDev;
return {
// TODO Remove this if we get EnvironmentPlugin to work.
root: 'web/src/main/webapp',
publicDir: publicDir,
envPrefix: ['VITE_', 'CATS_EFFECT_'],
resolve: {
dedupe: ['react-is'],
alias: [
{
find: 'process',
replacement: 'process/browser',
},
{
find: '@sjs',
replacement: sjs,
},
{
find: '/common',
replacement: webappCommon,
},
{
find: '/images',
replacement: imagesCommon,
}
],
},
css: {
preprocessorOptions: {
scss: {
charset: false,
},
},
},
server: {
strictPort: true,
fsServe: {
strict: true,
},
host: '0.0.0.0',
port: 8080,
https: true,
watch: {
ignored: [
function ignoreThisPath(_path) {
const sjsIgnored =
_path.includes('/target/stream') ||
_path.includes('/zinc/') ||
_path.includes('/classes') ||
_path.endsWith('.tmp');
return sjsIgnored;
}
]
}
},
build: {
emptyOutDir: true,
chunkSizeWarningLimit: 20000,
outDir: path.resolve(__dirname, 'deploy/static'),
},
plugins: [
isProduction
? null
: mkcert.default({ hosts: ['localhost', 'local.lucuma.xyz'] }),
react(),
],
};
};