mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The React bindings, the shim standing in for their peer, and four dead alias lines all resolved to upstream packages. So did the illustrations, the logo and the typeface, through `@hanzo/brand`. `@hanzo/react` now resolves to `@hanzo/insights-react`, which we publish. Its peer is `@hanzo/insights` by name, so `common/sdk-peer` -- a workspace package named `posthog-js` purely to satisfy the old peer -- is gone, and with it the last thing in the tree carrying that name. The fork exports `Insights*` where upstream exported `PostHog*`, so eight files stop aliasing an upstream identifier on import, and the eight allowlist entries excusing them are dropped. `@hanzo/brand` is removed rather than forked. It is licensed PolyForm Strict 1.0.0: noncommercial use only, no derivative works, no redistribution, and the illustrations are upstream trademarks. Forking it was never available to us, and neither was the commercial use we were already making of it. It carried three separate things, and each ends differently. The illustrations were decoration beside real content, so the 106 call sites keep their component and lose the artwork -- the shape `lib/components/mascots.tsx` already used. Two had been repurposed as real icons; those take the house fallback icon. The logo is real UI chrome, so it is rebuilt on Hanzo's own mark, the same glyph as the favicon: monochrome and `currentColor`, so it inherits the surrounding text colour instead of needing a variant per theme, and resolves inside the toolbar's shadow DOM where the old gradient's `url(#...)` fills did not. The typeface becomes Geist, already vendored here under SIL OFL and already the house face everywhere else. Four alias lines named packages nothing installs. pnpm echoes the override block into the lockfile verbatim, so they put an upstream name there for nothing. `bin/debrand --check` now refuses a manifest naming an upstream package unless it is listed with a reason, keyed by package rather than by file so an exemption cannot cover a whole manifest's future dependencies. Six remain, each with the reason it is still upstream's. The check found two nobody had noticed: `cli` and `rust` rename upstream crates with Cargo's `package =` key, the same aliasing on a different registry. The lockfile goes from 94 upstream references to 36.
143 lines
6.5 KiB
TypeScript
143 lines
6.5 KiB
TypeScript
import tailwindcss from '@tailwindcss/vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { dirname, resolve } from 'node:path'
|
|
import { URL, fileURLToPath } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
// import { toolbarDenylistPlugin } from './vite-toolbar-plugin'
|
|
import { htmlGenerationPlugin } from './plugins/vite-html-plugin'
|
|
import { insightsJsPlugin } from './plugins/vite-insights-js-plugin'
|
|
import { publicAssetsPlugin } from './plugins/vite-public-assets-plugin'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ mode }) => {
|
|
const isDev = mode === 'development'
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
// We delete and copy the HTML files for development
|
|
htmlGenerationPlugin(),
|
|
// Copy public assets to src/assets for development
|
|
publicAssetsPlugin(),
|
|
// Copy insights-js files from node_modules to dist for development
|
|
insightsJsPlugin(),
|
|
{
|
|
name: 'startup-message',
|
|
configureServer(server) {
|
|
server.httpServer?.once('listening', () => {
|
|
setTimeout(() => {
|
|
console.info(`
|
|
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
|
|
|
🚀 Visit http://localhost:8010 to see the app
|
|
⚠️ You may need to wait for the other services to start
|
|
|
|
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
|
`)
|
|
}, 1000)
|
|
})
|
|
},
|
|
},
|
|
],
|
|
resolve: {
|
|
dedupe: ['@base-ui/react'],
|
|
alias: {
|
|
'@base-ui/react': resolve(__dirname, 'node_modules/@base-ui/react'),
|
|
'~': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
// Add direct mappings for Insights's import structure from tsconfig.json
|
|
lib: resolve(__dirname, 'src/lib'),
|
|
scenes: resolve(__dirname, 'src/scenes'),
|
|
queries: resolve(__dirname, 'src/queries'),
|
|
layout: resolve(__dirname, 'src/layout'),
|
|
toolbar: resolve(__dirname, 'src/toolbar'),
|
|
taxonomy: resolve(__dirname, 'src/taxonomy'),
|
|
models: resolve(__dirname, 'src/models'),
|
|
mocks: resolve(__dirname, 'src/mocks'),
|
|
exporter: resolve(__dirname, 'src/exporter'),
|
|
types: resolve(__dirname, 'src/types.ts'),
|
|
// @hanzo/elements aliases
|
|
'@hanzo/elements': resolve(__dirname, '@hanzo/elements/src/index'),
|
|
'@hanzo/elements/': resolve(__dirname, '@hanzo/elements/src/'),
|
|
// Other aliases from tsconfig.json
|
|
storybook: resolve(__dirname, '../.storybook'),
|
|
// Just for Vite: we copy public assets to src/assets, we need to alias it to the correct path
|
|
public: resolve(__dirname, 'src/assets'),
|
|
// Required for production builds — @hanzo/icons is in the pnpm store, not node_modules root
|
|
'@hanzo/icons': resolve(__dirname, 'node_modules/@hanzo/icons'),
|
|
products: resolve(__dirname, '../products'),
|
|
'@hanzo/shared-onboarding': resolve(__dirname, '../docs/onboarding'),
|
|
'@hanzo/shared-onboarding/*': resolve(__dirname, '../docs/onboarding/*'),
|
|
// Node.js polyfills for browser compatibility
|
|
buffer: 'buffer',
|
|
},
|
|
},
|
|
build: {
|
|
// Generate manifest for backend integration
|
|
manifest: true,
|
|
outDir: 'dist',
|
|
rollupOptions: {
|
|
input: {
|
|
index: resolve(__dirname, 'src/index.tsx'),
|
|
exporter: resolve(__dirname, 'src/exporter/index.tsx'),
|
|
render_query: resolve(__dirname, 'src/render-query/index.tsx'),
|
|
toolbar: resolve(__dirname, 'src/toolbar/index.tsx'),
|
|
},
|
|
output: {
|
|
entryFileNames: isDev ? '[name].js' : '[name]-[hash].js',
|
|
chunkFileNames: isDev ? 'chunk-[name].js' : 'chunk-[name]-[hash].js',
|
|
assetFileNames: isDev ? '~/assets/[name].[ext]' : '~/assets/[name]-[hash].[ext]',
|
|
},
|
|
},
|
|
sourcemap: true,
|
|
},
|
|
worker: {
|
|
format: 'es', // Use ES modules to support WASM imports
|
|
plugins: () => [react()],
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: isDev ? '[name].js' : '[name]-[hash].js',
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 8234,
|
|
// The rest of the stack hardcodes 8234, so falling back to another port serves a
|
|
// broken app (the browser keeps talking to whatever squats 8234). Fail loudly instead;
|
|
// bin/start-frontend reclaims the port from stale processes before launching.
|
|
strictPort: true,
|
|
host: process.argv.includes('--host') ? '0.0.0.0' : 'localhost',
|
|
allowedHosts: process.env.VITE_ALLOWED_HOSTS?.split(',')
|
|
.map((s) => s.trim())
|
|
.filter(Boolean),
|
|
// nosemgrep: trailofbits.javascript.apollo-graphql.v3-cors-audit.v3-potentially-bad-cors
|
|
cors: true,
|
|
// JS_URL overrides for sandbox environments where Vite is exposed on a different port.
|
|
origin: process.env.JS_URL || 'http://localhost:8234',
|
|
hmr: process.env.JS_URL ? { clientPort: parseInt(process.env.JS_URL.split(':').pop()!) } : undefined,
|
|
proxy: {
|
|
'/static': {
|
|
target: 'http://localhost:8000',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
define: {
|
|
global: 'globalThis',
|
|
'process.env.NODE_ENV': isDev ? '"development"' : '"production"',
|
|
},
|
|
css: {
|
|
devSourcemap: true,
|
|
},
|
|
optimizeDeps: {
|
|
include: ['react', 'react-dom', 'buffer'],
|
|
// snappy-wasm: don't pre-bundle so the WASM file stays with the JS.
|
|
exclude: ['snappy-wasm'],
|
|
},
|
|
}
|
|
})
|