From 4005d0e8679c5ad11836de2b529a53d49595f402 Mon Sep 17 00:00:00 2001 From: Maxi Date: Wed, 10 Apr 2024 09:30:43 +0200 Subject: [PATCH] added DEPLOYMENT_MODE variable --- .github/workflows/deploy.yaml | 2 +- .gitignore | 1 + .vitepress/config.ts | 7 ++++--- .vitepress/vite.config.ts | 7 +++---- components.d.ts | 2 -- package.json | 5 +++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index d3041e9..213b20e 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -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 diff --git a/.gitignore b/.gitignore index ea51d69..9a1234d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules .vitepress/cache .vitepress/dist +.vitepress/.temp # Ignore dynamically built web-client docs build/web-client diff --git a/.vitepress/config.ts b/.vitepress/config.ts index d710de6..e278969 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -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' @@ -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, diff --git a/.vitepress/vite.config.ts b/.vitepress/vite.config.ts index 4238a59..5c13088 100644 --- a/.vitepress/vite.config.ts +++ b/.vitepress/vite.config.ts @@ -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() diff --git a/components.d.ts b/components.d.ts index 2cbdab7..53abf5a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -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'] } } diff --git a/package.json b/package.json index fed6d22..decab90 100644 --- a/package.json +++ b/package.json @@ -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",