2022-06-17 12:36:21 +02:00
|
|
|
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';
|
|
|
|
|
2022-06-23 11:47:59 +02:00
|
|
|
const plugins = [
|
|
|
|
RubyPlugin(),
|
2023-05-04 14:01:35 +02:00
|
|
|
ViteReact({ jsxRuntime: 'classic' }),
|
2024-01-17 09:32:36 +01:00
|
|
|
FullReload(['config/routes.rb', 'app/views/**/*', 'app/components/**/*.haml'], { delay: 200 })
|
2022-06-23 11:47:59 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
if (shouldBuildLegacy()) {
|
|
|
|
plugins.push(
|
2022-06-17 12:36:21 +02:00
|
|
|
ViteLegacy({
|
|
|
|
targets: [
|
|
|
|
'defaults',
|
|
|
|
'Chrome >= 50',
|
|
|
|
'Edge >= 14',
|
|
|
|
'Firefox >= 50',
|
|
|
|
'Opera >= 40',
|
|
|
|
'Safari >= 8',
|
|
|
|
'iOS >= 8',
|
|
|
|
'IE >= 11'
|
|
|
|
],
|
|
|
|
additionalLegacyPolyfills: [
|
2022-07-19 10:20:12 +02:00
|
|
|
'dom4',
|
2022-07-19 08:39:05 +02:00
|
|
|
'core-js/stable',
|
2022-06-17 12:36:21 +02:00
|
|
|
'@stimulus/polyfills',
|
2022-07-19 13:06:45 +02:00
|
|
|
'turbo-polyfills',
|
2022-06-17 12:36:21 +02:00
|
|
|
'intersection-observer',
|
|
|
|
'regenerator-runtime/runtime',
|
|
|
|
'whatwg-fetch',
|
|
|
|
'yet-another-abortcontroller-polyfill'
|
|
|
|
]
|
|
|
|
})
|
2022-06-23 11:47:59 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
resolve: { alias: { '@utils': '/shared/utils.ts' } },
|
2022-07-01 10:27:09 +02:00
|
|
|
build: { sourcemap: true },
|
2022-06-23 11:47:59 +02:00
|
|
|
plugins
|
2022-06-17 12:36:21 +02:00
|
|
|
});
|
2022-06-23 11:47:59 +02:00
|
|
|
|
|
|
|
function shouldBuildLegacy() {
|
|
|
|
if (process.env.VITE_LEGACY == 'disabled') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
process.env.RAILS_ENV == 'production' ||
|
|
|
|
process.env.VITE_LEGACY == 'enabled'
|
|
|
|
);
|
|
|
|
}
|