mirror of
https://github.com/enso-org/enso.git
synced 2024-12-18 07:42:21 +03:00
ebf4cd5c1f
- Remove unnecessary modules - Remove `ts-plugin-namespace-auto-import` as it was a workaround to use the non-conventional `import *` convention - Remove `esbuild-plugin-copy-directories` as it is unuse - Inline modules that are only ever used once - Inline `project-manager-shim` into `gui2` - it is only used during `gui2`'s dev mode - Inline `content-config` into `client` - Flatten `app/ide-desktop/lib/` to `app/ide-desktop/` - Flatten `app/ide-desktop/lib/dashboard/` to `app/dashboard/` # Important Notes - As mentioned above, all remaining modules have been moved up from `app/ide-desktop/lib/` to `app/ide-desktop/`. It's not ideal but I'd rather hold off on moving them anywhere else before we have a consensus on what should go where. - (That is to say, this may not be the final directory structure - but I figure it's fine to get *something* done so that hopefully the rest of the restructuring is simpler.)
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
/** @file Configuration for vite. */
|
|
import * as fsSync from 'node:fs'
|
|
import * as url from 'node:url'
|
|
|
|
import vitePluginYaml from '@modyfi/vite-plugin-yaml'
|
|
import vitePluginReact from '@vitejs/plugin-react'
|
|
import * as vite from 'vite'
|
|
|
|
import * as common from 'enso-common'
|
|
import * as appConfig from 'enso-common/src/appConfig'
|
|
|
|
// =====================
|
|
// === Configuration ===
|
|
// =====================
|
|
|
|
const HTTP_STATUS_OK = 200
|
|
const SERVER_PORT = 8080
|
|
await appConfig.readEnvironmentFromFile()
|
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
export default vite.defineConfig({
|
|
server: { port: SERVER_PORT, headers: Object.fromEntries(common.COOP_COEP_CORP_HEADERS) },
|
|
plugins: [
|
|
vitePluginReact({
|
|
include: '**/*.tsx',
|
|
babel: { plugins: ['@babel/plugin-syntax-import-attributes'] },
|
|
}),
|
|
vitePluginYaml(),
|
|
serveFavicon(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'#': url.fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
main: url.fileURLToPath(new URL('./index.html', import.meta.url)),
|
|
'404': url.fileURLToPath(new URL('./404.html', import.meta.url)),
|
|
},
|
|
},
|
|
},
|
|
define: {
|
|
// The sole hardcoded usage of `global` in aws-amplify.
|
|
'global.TYPED_ARRAY_SUPPORT': JSON.stringify(true),
|
|
...appConfig.getDefines(),
|
|
},
|
|
})
|
|
|
|
/** A plugin to serve a favicon, in development mode only. */
|
|
function serveFavicon(): vite.Plugin {
|
|
const favicon = fsSync.readFileSync(url.fileURLToPath(new URL('./favicon.ico', import.meta.url)))
|
|
const headers: HeadersInit = [
|
|
['Content-Length', String(favicon.length)],
|
|
['Content-Type', 'image/png'],
|
|
...common.COOP_COEP_CORP_HEADERS,
|
|
]
|
|
return {
|
|
name: 'serve-favicon',
|
|
configureServer: server => {
|
|
server.middlewares.use((req, res, next) => {
|
|
if (req.url === '/favicon.ico') {
|
|
res.writeHead(HTTP_STATUS_OK, headers).end(favicon)
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|