Skip to content

Commit

Permalink
added DEPLOYMENT_MODE variable
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Apr 10, 2024
1 parent cc57ced commit 4005d0e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: pnpm install
- name: Build with VitePress
run: |
pnpm build --mode staging
pnpm build:staging
ls build/web-client
touch .vitepress/dist/.nojekyll
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.vitepress/cache
.vitepress/dist
.vitepress/.temp

# Ignore dynamically built web-client docs
build/web-client
Expand Down
7 changes: 4 additions & 3 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { existsSync } from 'node:fs'
import { basename, dirname, join } from 'node:path'
import { env } from 'node:process'
import { defineConfig } from 'vitepress'
import { defineConfig, resolveConfig } from 'vitepress'
import { spawn } from 'cross-spawn'
import { readPackageJSON } from 'pkg-types'
import consola from 'consola'
import { sidebar } from './sidebar.config'
import { navigation } from './navigation.config'

Expand All @@ -12,11 +13,11 @@ import { navigation } from './navigation.config'
// https://vitepress.dev/reference/site-config
export default async () => {
const { title, description, homepage } = await readPackageJSON()
const isProduction = env.NODE_ENV === 'production'
const isProduction = env.DEPLOYMENT_MODE === 'production'
const baseUrl = isProduction ? '/developers' : '/developer-center/'
consola.info(`Building for ${isProduction ? 'production' : 'development'}. The base URL is ${baseUrl}`)

return defineConfig({
base: baseUrl,
title,
srcExclude: ['**/README.md'],
description,
Expand Down
7 changes: 3 additions & 4 deletions .vitepress/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import { getGitStats } from './scripts/git-stats'
import { generateWebClientDocs } from './scripts/web-client'
import { generateRpcDocs } from './scripts/rpc-docs'

export default defineConfig(async ({ mode }) => {
export default defineConfig(async () => {
const { specUrl, specVersion } = await generateRpcDocs()
await generateWebClientDocs()

const environment = env.NODE_ENV || mode

consola.debug(`Building for ${environment}`)
const environment = env.DEPLOYMENT_MODE
consola.info(`Building for ${environment}`)

const { albatrossCommitDate, albatrossCommitHash, commitHash, commitUrl, repoUrl } = await getGitStats()

Expand Down
2 changes: 0 additions & 2 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ declare module 'vue' {
Tags: typeof import('./.vitepress/theme/components/Tags.vue')['default']
ThemeSwitcher: typeof import('./.vitepress/theme/components/header/ThemeSwitcher.vue')['default']
Toast: typeof import('./.vitepress/theme/components/Toast.vue')['default']
TwoColumn: typeof import('./.vitepress/theme/components/TwoColumn.vue')['default']
TwoColumns: typeof import('./.vitepress/theme/components/TwoColumns.vue')['default']
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
},
"homepage": "https://nimiq.github.io/developer-center/",
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"dev": "DEPLOYMENT_MODE=development vitepress dev",
"build": "DEPLOYMENT_MODE=production vitepress build",
"build:staging": "DEPLOYMENT_MODE=staging vitepress build",
"preview": "vitepress preview",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand Down

0 comments on commit 4005d0e

Please sign in to comment.