Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 15ea951

Browse files
authored
chore(svelte): Simplify development for dotcom (#63341)
Whether or not the app is in "dotcom mode" is determined by `window.context.sourcegraphDotComMode`. In development we use a stub `window.context` object defined in `app.html`. This commit extends that object to set `sourcegraphDotComMode` depending on an environment varible. The environment variable is set by using vite modes (https://vitejs.dev/guide/env-and-mode.html). The whole setup can be started with `pnpm dev:dotcom`. ## Test plan Ran `pnpm dev:dotcom` and saw the dotcom specific header and footer.
1 parent d2d4491 commit 15ea951

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

client/web-sveltekit/.env.dotcom

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
PUBLIC_SG_ENTERPRISE=true
21
PUBLIC_DOTCOM=true

client/web-sveltekit/.env.oss

Lines changed: 0 additions & 2 deletions
This file was deleted.

client/web-sveltekit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1",
44
"scripts": {
55
"dev": "vite dev",
6-
"dev:dotcom": "vite dev --mode=dotcom",
6+
"dev:dotcom": "SOURCEGRAPH_API_URL=https://sourcegraph.com vite dev --mode=dotcom",
77
"dev:enterprise": "DEPLOY_TYPE=dev vite build --watch",
88
"build": "vite build",
99
"build:preview": "vite build --mode=preview",

client/web-sveltekit/src/app.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
<!-- Template used for local development only -->
23
<html lang="en">
34
<head>
45
<meta charset="utf-8" />
@@ -16,6 +17,9 @@
1617
xhrHeaders: {
1718
'X-Requested-With': 'Sourcegraph',
1819
},
20+
// Local standalone dev server for dotcom can be started with
21+
// pnpm dev:dotcom
22+
sourcegraphDotComMode: '%sveltekit.env.PUBLIC_DOTCOM%' ? true : false,
1923
}
2024
window.pageError = undefined
2125
</script>

0 commit comments

Comments
 (0)