Skip to content

Commit

Permalink
fix no build info in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Dec 17, 2024
1 parent ea1dd5e commit 8904fbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 14 additions & 0 deletions prismarine-viewer/rsbuildSharedConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginBasicSsl } from '@rsbuild/plugin-basic-ssl'
import path from 'path'
import fs from 'fs'

let releaseTag
let releaseChangelog

if (fs.existsSync('./assets/release.json')) {
const releaseJson = JSON.parse(fs.readFileSync('./assets/release.json', 'utf8'))
releaseTag = releaseJson.latestTag
releaseChangelog = releaseJson.changelog?.replace(/<!-- bump-type:[\w]+ -->/, '')
}

export const appAndRendererSharedConfig = () => defineConfig({
dev: {
Expand Down Expand Up @@ -40,6 +50,10 @@ export const appAndRendererSharedConfig = () => defineConfig({
},
define: {
'process.platform': '"browser"',
'process.env.GITHUB_URL':
JSON.stringify(`https://github.com/${process.env.GITHUB_REPOSITORY || `${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}`}`),
'process.env.RELEASE_TAG': JSON.stringify(releaseTag),
'process.env.RELEASE_CHANGELOG': JSON.stringify(releaseChangelog),
},
decorators: {
version: 'legacy', // default is a lie
Expand Down
13 changes: 0 additions & 13 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ const buildingVersion = new Date().toISOString().split(':')[0]

const dev = process.env.NODE_ENV === 'development'

let releaseTag
let releaseChangelog

if (fs.existsSync('./assets/release.json')) {
const releaseJson = JSON.parse(fs.readFileSync('./assets/release.json', 'utf8'))
releaseTag = releaseJson.latestTag
releaseChangelog = releaseJson.changelog?.replace(/<!-- bump-type:[\w]+ -->/, '')
}

// base options are in ./prismarine-viewer/rsbuildSharedConfig.ts
const appConfig = defineConfig({
html: {
Expand All @@ -54,11 +45,7 @@ const appConfig = defineConfig({
define: {
'process.env.BUILD_VERSION': JSON.stringify(!dev ? buildingVersion : 'undefined'),
'process.env.MAIN_MENU_LINKS': JSON.stringify(process.env.MAIN_MENU_LINKS),
'process.env.GITHUB_URL':
JSON.stringify(`https://github.com/${process.env.GITHUB_REPOSITORY || `${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}`}`),
'process.env.DEPS_VERSIONS': JSON.stringify({}),
'process.env.RELEASE_TAG': JSON.stringify(releaseTag),
'process.env.RELEASE_CHANGELOG': JSON.stringify(releaseChangelog),
},
},
server: {
Expand Down

0 comments on commit 8904fbf

Please sign in to comment.