forked from demarches-simplifiees/demarches-simplifiees.fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
54 lines (50 loc) · 1.27 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
import { defineConfig } from 'vite';
import ViteReact from '@vitejs/plugin-react';
import ViteLegacy from '@vitejs/plugin-legacy';
import FullReload from 'vite-plugin-full-reload';
import RubyPlugin from 'vite-plugin-ruby';
const plugins = [
RubyPlugin(),
ViteReact({ jsxRuntime: 'classic' }),
FullReload(['config/routes.rb', 'app/views/**/*', 'app/components/**/*.haml'], { delay: 200 })
];
if (shouldBuildLegacy()) {
plugins.push(
ViteLegacy({
targets: [
'defaults',
'Chrome >= 50',
'Edge >= 14',
'Firefox >= 50',
'Opera >= 40',
'Safari >= 8',
'iOS >= 8',
'IE >= 11'
],
additionalLegacyPolyfills: [
'dom4',
'core-js/stable',
'@stimulus/polyfills',
'turbo-polyfills',
'intersection-observer',
'regenerator-runtime/runtime',
'whatwg-fetch',
'yet-another-abortcontroller-polyfill'
]
})
);
}
export default defineConfig({
resolve: { alias: { '@utils': '/shared/utils.ts' } },
build: { sourcemap: true },
plugins
});
function shouldBuildLegacy() {
if (process.env.VITE_LEGACY == 'disabled') {
return false;
}
return (
process.env.RAILS_ENV == 'production' ||
process.env.VITE_LEGACY == 'enabled'
);
}