From 0c2ba48eb261001caf3b9d8c885a11b912a9a223 Mon Sep 17 00:00:00 2001 From: Johannes Zillmann Date: Fri, 5 Mar 2021 20:51:38 +0100 Subject: [PATCH] Bundling in production --- ui/snowpack.config.js | 10 ++++++++-- ui/src/store.ts | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/snowpack.config.js b/ui/snowpack.config.js index 8c111a3..6245687 100644 --- a/ui/snowpack.config.js +++ b/ui/snowpack.config.js @@ -4,7 +4,12 @@ module.exports = { public: { url: '/', static: true }, src: { url: '/dist' }, '../core/src': { url: '/core' }, - 'node_modules/pdfjs-dist/build/': { url: '/worker', static: true }, + 'node_modules/pdfjs-dist/es5/build/': { url: '/worker', static: true }, + }, + optimize: { + bundle: true, + minify: true, + target: 'es2020', }, plugins: [ ['@snowpack/plugin-build-script', { cmd: 'postcss', input: ['.css'], output: ['.css'] }], @@ -21,7 +26,8 @@ module.exports = { port: 3005, }, buildOptions: { - /* ... */ + baseUrl: '/pdf-to-markdown-staging/', + metaUrlPath: 'modules', }, alias: { '@core': '../core/src/index.js', diff --git a/ui/src/store.ts b/ui/src/store.ts index 3d98a38..7fd43db 100644 --- a/ui/src/store.ts +++ b/ui/src/store.ts @@ -9,12 +9,12 @@ import { Writable, writable } from 'svelte/store'; export let debug: Writable = writable(undefined); export let parseResult: Writable = writable(undefined); -pdfjs.GlobalWorkerOptions.workerSrc = 'worker/pdf.worker.min.js'; +pdfjs.GlobalWorkerOptions.workerSrc = `worker/pdf.worker.min.js`; const pdfPipeline = createPipeline(pdfjs, {}); export async function loadExample(progressListener: ProgressListenFunction): Promise { - return parsePdf('/ExamplePdf.pdf', progressListener); + return parsePdf('ExamplePdf.pdf', progressListener); } export async function processUpload(file: File, progressListener: ProgressListenFunction): Promise {