The screenshot images for the welcome overlay (both in Svelte and React) are quite large. In Svelte specifically, because they are implemented as Svelte components, this adds a lot of code to the root layout and makes the bundle quite large. This commit converts the Svelte components to image files and passes them (and the React ones) through [svgo](https://github.com/svg/svgo). On one hand that makes the images much smaller, on the other hand in Svelte the images are now independent of the JS code and can be loaded separately (the React app was already using an `img` element). Before svgo: ``` $ ls src/lib/assets/ total 3.1M 5.1K Aug 7 18:45 sourcegraph-logo.svg 1.5M Aug 7 18:46 welcome-screenshot-dark.svg 1.6M Aug 7 18:46 welcome-screenshot-light.svg ``` After svgo: ``` $ ls src/lib/assets/ total 1.4M 5.1K Aug 7 18:45 sourcegraph-logo.svg 667K Aug 7 18:50 welcome-screenshot-dark.svg 667K Aug 7 18:50 welcome-screenshot-light.svg ``` ## Test plan I temporarily changed the code so that the welcome dialog is always shown in the Svelte app and inspected the image. It still seems to look the same. |
||
|---|---|---|
| .. | ||
| __mocks__ | ||
| bookmarklet | ||
| dev | ||
| dist | ||
| src | ||
| tests-examples | ||
| .bazelignore | ||
| .eslintignore | ||
| .stylelintrc.json | ||
| BUILD.bazel | ||
| bundlesize.config.js | ||
| package.json | ||
| README.md | ||
| statoscope | ||
| tsconfig.json | ||
| vitest.config.ts | ||
Web Application
Local development
Use sg CLI tool to configure and start local development server. For more information check out the sg documentation.
Our local development server runs by starting both a Caddy HTTPS server and a Node HTTP server. We then can reverse proxy requests to the Node server to serve client assets under HTTPS.
Configuration
Environment variables important for the web server:
WEB_BUILDER_SERVE_INDEXshould be set totrueto enable serving of an index page.SOURCEGRAPH_API_URLis used as a proxied API url. By default it points to the https://k8s.sgdev.org.
It's possible to overwrite these variables by creating sg.config.overwrite.yaml in the root folder and adjusting the env section of the relevant command.
Development server
sg start web-standalone
Public API
To use a public API that doesn't require authentication for most of the functionality:
SOURCEGRAPH_API_URL=https://sourcegraph.com sg start web-standalone
Production server
sg start web-standalone-prod
Web app should be available at https://${SOURCEGRAPH_HTTPS_DOMAIN}:${SOURCEGRAPH_HTTPS_PORT}. Build artifacts will be served from <rootRepoPath>/client/web/dist.
Note: If you are unable to use the above commands (e.g. you can't install Caddy), you can use sg run web-standalone-http instead. This will start a development server using only Node, and will be available at http://localhost:${SOURCEGRAPH_HTTP_PORT}.
API proxy
In both environments, server proxies API requests to SOURCEGRAPH_API_URL provided as the .env variable.