pdf.js 5.x декодирует JBIG2/JPEG2000/ICC через wasm и без опции wasmUrl падает:
«JBig2 failed to initialize», «Unable to decode image» (AURORA-1635).
- rsbuild: output.copy node_modules/pdfjs-dist/wasm -> static/pdfjs/wasm;
- pdfjsOptions.ts: pdfjsWasmUrl(APP_ADDRESS) с учётом ROOT_PATH (+ тест);
- PdfPages: getDocument({ wasmUrl }). Legacy-сборка pdf.js сохранена (#22).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { defineConfig, loadEnv } from '@rsbuild/core';
|
||
import { pluginReact } from '@rsbuild/plugin-react';
|
||
|
||
const { publicVars, rawPublicVars } = loadEnv({prefixes: ['REACT_APP_']});
|
||
|
||
export default defineConfig({
|
||
server: {
|
||
base: (rawPublicVars['REACT_APP_ROOT_PATH'] !== undefined) ? rawPublicVars['REACT_APP_ROOT_PATH'] : '/',
|
||
proxy: {
|
||
// dev: запросы /api идут на arm-core с того же источника — без CORS, Content-Disposition читается (design D-5)
|
||
'/api': process.env.ARM_CORE_URL ?? 'http://localhost:8000',
|
||
},
|
||
},
|
||
output: {
|
||
// wasm-декодеры pdf.js (JBIG2, JPEG2000, ICC): без них скан не рисуется (AURORA-1635). Путь = PDFJS_WASM_DIR
|
||
copy: [{ from: 'node_modules/pdfjs-dist/wasm', to: 'static/pdfjs/wasm' }],
|
||
filename: {
|
||
js: '[name]_script.[contenthash:8].js',
|
||
css: '[name]_style.[contenthash:8].css',
|
||
},
|
||
distPath: {
|
||
favicon: 'static/image',
|
||
},
|
||
assetPrefix: (rawPublicVars['REACT_APP_ROOT_PATH'] !== undefined) ? rawPublicVars['REACT_APP_ROOT_PATH'] : './'
|
||
},
|
||
html: {
|
||
template: './public/index.html',
|
||
favicon: './src/assets/favicon.ico',
|
||
},
|
||
source: {
|
||
include: [{ not: /[\\/]core-js[\\/]/ }],
|
||
define: {
|
||
...publicVars,
|
||
'process.env': JSON.stringify(rawPublicVars),
|
||
}
|
||
},
|
||
plugins: [pluginReact()],
|
||
});
|