2023-11-29 20:29:25 +03:00
|
|
|
/** @file Configuration for vite. */
|
2024-01-10 19:22:11 +03:00
|
|
|
import * as url from 'node:url'
|
|
|
|
|
2023-11-29 20:29:25 +03:00
|
|
|
import vitePluginYaml from '@modyfi/vite-plugin-yaml'
|
2024-01-10 19:22:11 +03:00
|
|
|
import vitePluginReact from '@vitejs/plugin-react'
|
|
|
|
import * as vite from 'vite'
|
2023-11-29 20:29:25 +03:00
|
|
|
|
2024-03-08 06:14:26 +03:00
|
|
|
import * as common from 'enso-common'
|
|
|
|
import * as appConfig from 'enso-common/src/appConfig'
|
2023-11-29 20:29:25 +03:00
|
|
|
|
|
|
|
// =====================
|
|
|
|
// === Configuration ===
|
|
|
|
// =====================
|
|
|
|
|
2024-03-08 06:14:26 +03:00
|
|
|
const SERVER_PORT = 8080
|
|
|
|
await appConfig.readEnvironmentFromFile()
|
2023-11-29 20:29:25 +03:00
|
|
|
|
2024-03-08 06:14:26 +03:00
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
2023-11-29 20:29:25 +03:00
|
|
|
export default vite.defineConfig({
|
2024-03-08 06:14:26 +03:00
|
|
|
server: { port: SERVER_PORT, headers: Object.fromEntries(common.COOP_COEP_CORP_HEADERS) },
|
2024-02-12 13:05:30 +03:00
|
|
|
plugins: [
|
|
|
|
vitePluginReact({
|
|
|
|
include: '**/*.tsx',
|
2024-03-08 06:14:26 +03:00
|
|
|
babel: { plugins: ['@babel/plugin-syntax-import-assertions'] },
|
2024-02-12 13:05:30 +03:00
|
|
|
}),
|
|
|
|
vitePluginYaml(),
|
|
|
|
],
|
2024-01-10 19:22:11 +03:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'#': url.fileURLToPath(new URL('./src', import.meta.url)),
|
2023-11-29 20:29:25 +03:00
|
|
|
},
|
2024-01-23 00:26:15 +03:00
|
|
|
},
|
2024-01-31 14:35:41 +03:00
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
main: url.fileURLToPath(new URL('./index.html', import.meta.url)),
|
|
|
|
'404': url.fileURLToPath(new URL('./404.html', import.meta.url)),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-11-29 20:29:25 +03:00
|
|
|
define: {
|
|
|
|
IS_VITE: JSON.stringify(true),
|
2024-03-08 06:14:26 +03:00
|
|
|
// The sole hardcoded usage of `global` in aws-amplify.
|
2023-11-29 20:29:25 +03:00
|
|
|
'global.TYPED_ARRAY_SUPPORT': JSON.stringify(true),
|
2024-03-08 06:14:26 +03:00
|
|
|
...appConfig.getDefines(SERVER_PORT),
|
2024-01-23 00:26:15 +03:00
|
|
|
},
|
2023-11-29 20:29:25 +03:00
|
|
|
})
|