mirror of
https://github.com/enso-org/enso.git
synced 2024-12-11 14:35:56 +03:00
37d820c764
- Fixes #6168 - Removes `enso-copy-plugin` in favor of an inline plugin - It was only used in one place anyway - It is probably necessary since I've "fixed" it by adding all files as entrypoints (I'm not quite sure why it wasn't working with the fix with `enso-copy-plugin`...) - Adds live reload (back) to `content/` # Important Notes To QA: Mandatory: - `./run gui watch --skip-version-check --skip-wasm-opt` Recommended: - `npm run watch-dashboard` - `./run ide watch --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest` - and with `--ide-option -authentication` - `./run ide build --skip-version-check --skip-wasm-opt --backend-source release --backend-release latest` - `Enso` and `Enso -authentication`
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
/** @file File watch and compile service. */
|
|
import * as path from 'node:path'
|
|
import * as url from 'node:url'
|
|
|
|
import * as esbuild from 'esbuild'
|
|
import chalk from 'chalk'
|
|
|
|
import * as bundler from './esbuild-config'
|
|
|
|
export const THIS_PATH = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
|
|
|
|
// =================
|
|
// === Constants ===
|
|
// =================
|
|
|
|
/** This must be port `8081` because it is defined as such in AWS. */
|
|
const PORT = 8081
|
|
const HTTP_STATUS_OK = 200
|
|
// `outputPath` does not have to be a real directory because `write` is `false`,
|
|
// meaning that files will not be written to the filesystem.
|
|
// However, the path should still be non-empty in order for `esbuild.serve` to work properly.
|
|
const ARGS: bundler.Arguments = { outputPath: '/', devMode: true }
|
|
const OPTS = bundler.bundlerOptions(ARGS)
|
|
OPTS.entryPoints.push(
|
|
path.resolve(THIS_PATH, 'src', 'index.html'),
|
|
path.resolve(THIS_PATH, 'src', 'index.tsx'),
|
|
path.resolve(THIS_PATH, 'src', 'serviceWorker.ts')
|
|
)
|
|
OPTS.write = false
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
OPTS.loader = { '.html': 'copy' }
|
|
|
|
// ===============
|
|
// === Watcher ===
|
|
// ===============
|
|
|
|
async function watch() {
|
|
const builder = await esbuild.context(OPTS)
|
|
await builder.watch()
|
|
await builder.serve({
|
|
port: PORT,
|
|
servedir: OPTS.outdir,
|
|
onRequest(args) {
|
|
if (args.status !== HTTP_STATUS_OK) {
|
|
console.error(
|
|
chalk.red(`HTTP error ${args.status} when serving path '${args.path}'.`)
|
|
)
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
void watch()
|