Initial commit: 风影 OA 全栈源码(API/Web/Flutter/IM)
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { defineConfig, type Plugin } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { createReadStream, existsSync, cpSync, statSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
function pdfjsAssets(): Plugin {
|
||||
const root = path.resolve('node_modules/pdfjs-dist');
|
||||
return {
|
||||
name: 'pdfjs-assets',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
const url = (req.url || '').split('?')[0];
|
||||
if (!url.startsWith('/pdfjs/')) return next();
|
||||
const rel = decodeURIComponent(url.replace(/^\/pdfjs\//, ''));
|
||||
const file = path.resolve(root, rel);
|
||||
if (!file.startsWith(root) || !existsSync(file) || !statSync(file).isFile()) return next();
|
||||
if (file.endsWith('.bcmap')) res.setHeader('Content-Type', 'application/octet-stream');
|
||||
createReadStream(file).pipe(res);
|
||||
});
|
||||
},
|
||||
closeBundle() {
|
||||
const dest = path.resolve('dist/pdfjs');
|
||||
if (existsSync(path.join(root, 'cmaps'))) {
|
||||
cpSync(path.join(root, 'cmaps'), path.join(dest, 'cmaps'), { recursive: true });
|
||||
}
|
||||
if (existsSync(path.join(root, 'standard_fonts'))) {
|
||||
cpSync(path.join(root, 'standard_fonts'), path.join(dest, 'standard_fonts'), { recursive: true });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), pdfjsAssets()],
|
||||
worker: { format: 'es' },
|
||||
optimizeDeps: { include: ['pdfjs-dist'] },
|
||||
server: {
|
||||
host: true,
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': 'http://127.0.0.1:3000',
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user