openpencil/vite.config.ts
Vitali sharp8n 0ea0b1b4f0
Some checks failed
Build native contracts CI image / Publish native contracts image (push) Has been cancelled
chore: merge upstream/master into upstream-sync-2026-10
Bring the fork up to upstream v0.15.1 (637 commits). Conflicts resolved by
re-targeting the W4C delta onto upstream's restructured code and dropping
superseded changes:

- i18n: upstream split dialogs.json per feature; re-added webFontLoadFailed to
  the new fonts.json in all locales.
- automation: upstream moved the bridge into the MCP runtime and deleted
  EditorView.vue; re-added the served-build opt-in (?automation=1 /
  VITE_OPENPENCIL_AUTOMATION) with ?automationWs= and ?automationToken= via
  connectServedAutomation(), wired in WorkspaceView.
- fonts: kept the /__font-proxy fetch wrapper on top of upstream's
  browserWebFontFetch and re-enabled the Google provider in the web build.
- recovery/embed: kept auto-recover mode discarding snapshots (no dialog, no
  close prompt) and openFileReusingMatchingTab() for host pushes.
- io/capability: folded the cross-origin subframe guard into
  supportsFileSystemAccess()/pickBrowserSaveFile().
- embed bridge installed from boot.ts; MCP browserToken/tcpHost re-applied.
2026-10-08 23:21:00 +03:00

75 lines
2.7 KiB
TypeScript

import { resolve } from 'node:path'
import process from 'node:process'
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import { ensureBrandAssets } from '@open-pencil/brand-tools'
import { ensureDemoDocument } from '@open-pencil/demo-tools'
import packageJson from './package.json'
import { viteBuildTarget } from './src/app/shell/support/baseline'
import { createOpenPencilAliases } from './vite/aliases'
import {
localAutomationRoute,
localAutomationToken,
openPencilAutomationPlugin
} from './vite/automation'
import { copyCanvasKitAssetsPlugin } from './vite/canvaskit-assets'
import { createDevFontProxyPlugin } from './vite/font-proxy'
import { aiIconCollection } from './vite/icons'
import { openPencilPwaPlugin } from './vite/pwa'
import { rawMarkdownPlugin } from './vite/raw-markdown'
import { createDevServerOptions } from './vite/server'
const host = process.env.TAURI_DEV_HOST
const automationRoute = localAutomationRoute(host)
export default defineConfig(async ({ command }) => {
await Promise.all([ensureBrandAssets(['web']), ensureDemoDocument()])
return {
resolve: {
alias: createOpenPencilAliases(__dirname)
},
define: {
__OPENPENCIL_APP_VERSION__: JSON.stringify(packageJson.version),
__OPENPENCIL_LOCAL_AUTOMATION_TOKEN__: JSON.stringify(localAutomationToken(command)),
__OPENPENCIL_LOCAL_AUTOMATION_URL__: JSON.stringify(automationRoute.browserURL),
__OPENPENCIL_LOCAL_AUTOMATION_HTTP_URL__: JSON.stringify(
automationRoute.browserURL.replace(/^ws/, 'http')
)
},
// Dynamic browser fixtures must not trigger a dependency-optimizer reload mid-test.
optimizeDeps: { include: ['ai/test'] },
plugins: [
rawMarkdownPlugin(),
copyCanvasKitAssetsPlugin(),
tailwindcss(),
Icons({ compiler: 'vue3', customCollections: { ai: aiIconCollection() } }),
Components({ resolvers: [IconsResolver({ prefix: 'icon', customCollections: ['ai'] })] }),
openPencilAutomationPlugin(command, host),
vue(),
createDevFontProxyPlugin(),
openPencilPwaPlugin()
],
clearScreen: false,
build: {
// Syntax is lowered to the supported browser baseline; APIs are not polyfilled.
target: viteBuildTarget(),
chunkSizeWarningLimit: 2500,
rolldownOptions: {
// The desktop Software Update window is its own page.
input: {
main: resolve(__dirname, 'index.html'),
updater: resolve(__dirname, 'updater.html')
}
}
},
server: createDevServerOptions(host, __dirname)
}
})