enso/app/ide-desktop/client/esbuildConfig.ts
Sergei Garin 58512e701e
Show docs on Dashboard (#11391)
Closes: https://github.com/enso-org/cloud-v2/issues/1445

PR is more or less ready for feedback,CR, and QA.

# Read before looking into:

**Known issues:**
- [x] Need to adjust timings for the animations (they're a bit out of sync).
- [x] After the latest rebase, the side panel might expand while clicking on the sidebar toggle.
- [ ] Images no longer display. 🤦
- [x] Need to restore the functionality around spotlighting a component


Demo:

https://github.com/user-attachments/assets/8cec9ec0-4753-482e-8637-f3857b4396a5
2024-11-15 12:12:55 +00:00

58 lines
1.7 KiB
TypeScript

/** @file Esbuild config file. */
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
import type * as esbuild from 'esbuild'
import { wasmLoader } from 'esbuild-plugin-wasm'
import * as appConfig from 'enso-common/src/appConfig'
import * as paths from './paths'
await appConfig.readEnvironmentFromFile()
/**
* Get the bundler options using the environment.
*
* The following environment variables are required:
* - `ENSO_BUILD_IDE` - output directory for bundled client files;
* - `ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH` - path to the project manager executable relative
* to the PM bundle root;
* @see bundlerOptions
*/
export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions {
return bundlerOptions(
path.join(paths.getIdeDirectory(), 'client'),
paths.getProjectManagerInBundlePath(),
devMode,
)
}
/** Get options without relying on the environment. */
export function bundlerOptions(
outdir: string,
projectManagerInBundlePath: string,
devMode = false,
): esbuild.BuildOptions {
return {
bundle: true,
outdir,
entryPoints: ['src/index.ts', 'src/preload.ts'],
outbase: 'src',
format: 'esm',
platform: 'node',
outExtension: { '.js': '.mjs' },
plugins: [wasmLoader()],
target: ['node20'], // electron31
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
define: {
'process.env.PROJECT_MANAGER_IN_BUNDLE_PATH': JSON.stringify(projectManagerInBundlePath),
'process.env.ELECTRON_DEV_MODE': JSON.stringify(String(devMode)),
'process.env.GUI_CONFIG_PATH': JSON.stringify(path.resolve('../../gui/vite.config.ts')),
},
sourcemap: 'linked',
external: ['electron', 'vite', 'lightningcss'],
}
}