2026-04-05 18:31:16 -07:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import path from 'path'
|
2026-08-09 10:59:38 -07:00
|
|
|
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 {
|
2026-08-09 11:05:01 -07:00
|
|
|
sha = execSync('git rev-parse --short HEAD', {
|
|
|
|
|
cwd: __dirname,
|
|
|
|
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
|
|
|
}).toString().trim()
|
2026-08-09 10:59:38 -07:00
|
|
|
} catch {
|
|
|
|
|
// Building outside a git checkout (release tarball) -- keep 'nogit'.
|
|
|
|
|
}
|
|
|
|
|
return `${sha}-${new Date().toISOString().slice(0, 10)}`
|
|
|
|
|
})()
|
2026-04-05 18:31:16 -07:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
base: './',
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-08-09 10:59:38 -07:00
|
|
|
define: {
|
|
|
|
|
__EDITOR_BUILD__: JSON.stringify(editorBuild),
|
|
|
|
|
},
|
2026-04-05 18:31:16 -07:00
|
|
|
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: {
|
2026-07-12 14:59:42 -07:00
|
|
|
'/api': 'http://192.168.1.148:8080',
|
2026-04-05 18:31:16 -07:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|