Add office editor provider

This commit is contained in:
2026-09-14 18:08:20 -04:00
commit a4e8b147e3
14 changed files with 309 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
{
name: 'inject-css-filename',
enforce: 'post',
generateBundle(_options, bundle) {
const cssFile = Object.keys(bundle).find(name => name.endsWith('.css'))
if (!cssFile) return
for (const fileName of Object.keys(bundle)) {
const chunk = bundle[fileName]
if (chunk.type === 'chunk' && chunk.code.includes('__CSS_FILENAME_PLACEHOLDER__')) {
chunk.code = chunk.code.replace(/__CSS_FILENAME_PLACEHOLDER__/g, `static/${cssFile}`)
console.log(`Injected CSS filename "static/${cssFile}" into ${fileName}`)
}
}
}
}
],
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@KTXC': path.resolve(__dirname, '../../core/src'),
'@DocumentsManager': path.resolve(__dirname, '../documents_manager/src'),
},
},
build: {
outDir: 'static',
emptyOutDir: true,
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'src/main.ts'),
formats: ['es'],
fileName: () => 'module.mjs',
},
rollupOptions: {
external: [
'vue',
'vue-router',
'pinia',
'@KTXC',
/^@DocumentsManager\//,
],
output: {
paths: (id) => {
if (id === '@KTXC') return '/js/ktxc.mjs'
if (id.startsWith('@DocumentsManager/')) {
return '/modules/documents_manager/static/module.mjs'
}
return id
},
assetFileNames: (assetInfo) => {
if (assetInfo.name?.endsWith('.css')) {
return 'office-editor-[hash].css'
}
return '[name]-[hash][extname]'
}
}
},
},
})