Review found two real issues in the initial build-stamp commit: - A permanent, unconditional console.log on every editor load for every customer is production noise. Replaced with a window.__WHP_EDITOR_BUILD__ assignment -- same load-bearing effect (keeps build-stamp.ts from being tree-shaken out before Task 19 wires in the real call site), but prints nothing. Support can ask a user to type __WHP_EDITOR_BUILD__ in the console on request. Commented as load-bearing so it isn't later "cleaned up" as a stray global. - editorBuild()'s 'dev' fallback was never actually exercised by any test in the suite, despite the previous report claiming otherwise. Added build-stamp.test.ts asserting editorBuild() === 'dev' under vitest. Also silences the expected-failure stderr git prints on the successful 'nogit' fallback path (stdio: ['ignore', 'pipe', 'ignore']), so a release-tarball build log doesn't show a misleading fatal: line for an intentional, handled case. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
import { execSync } from 'child_process'
|
|
|
|
/** Short git SHA + build date, injected as __EDITOR_BUILD__ so an issue
|
|
* report identifies exactly which bundle produced it. package.json's
|
|
* version is hand-maintained and never changes between builds. */
|
|
const editorBuild = (() => {
|
|
let sha = 'nogit'
|
|
try {
|
|
sha = execSync('git rev-parse --short HEAD', {
|
|
cwd: __dirname,
|
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
}).toString().trim()
|
|
} catch {
|
|
// Building outside a git checkout (release tarball) -- keep 'nogit'.
|
|
}
|
|
return `${sha}-${new Date().toISOString().slice(0, 10)}`
|
|
})()
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
base: './',
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
define: {
|
|
__EDITOR_BUILD__: JSON.stringify(editorBuild),
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: 'js/editor.js',
|
|
chunkFileNames: 'js/[name].js',
|
|
assetFileNames: (info) =>
|
|
info.name?.endsWith('.css') ? 'css/editor.css' : 'assets/[name][extname]',
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: {
|
|
'/api': 'http://192.168.1.148:8080',
|
|
},
|
|
},
|
|
})
|