Bundling in production

This commit is contained in:
Johannes Zillmann 2021-03-05 20:51:38 +01:00
parent e2ed193967
commit 0c2ba48eb2
2 changed files with 10 additions and 4 deletions

View File

@ -4,7 +4,12 @@ module.exports = {
public: { url: '/', static: true }, public: { url: '/', static: true },
src: { url: '/dist' }, src: { url: '/dist' },
'../core/src': { url: '/core' }, '../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: [ plugins: [
['@snowpack/plugin-build-script', { cmd: 'postcss', input: ['.css'], output: ['.css'] }], ['@snowpack/plugin-build-script', { cmd: 'postcss', input: ['.css'], output: ['.css'] }],
@ -21,7 +26,8 @@ module.exports = {
port: 3005, port: 3005,
}, },
buildOptions: { buildOptions: {
/* ... */ baseUrl: '/pdf-to-markdown-staging/',
metaUrlPath: 'modules',
}, },
alias: { alias: {
'@core': '../core/src/index.js', '@core': '../core/src/index.js',

View File

@ -9,12 +9,12 @@ import { Writable, writable } from 'svelte/store';
export let debug: Writable<Debugger> = writable(undefined); export let debug: Writable<Debugger> = writable(undefined);
export let parseResult: Writable<ParseResult> = writable(undefined); export let parseResult: Writable<ParseResult> = writable(undefined);
pdfjs.GlobalWorkerOptions.workerSrc = 'worker/pdf.worker.min.js'; pdfjs.GlobalWorkerOptions.workerSrc = `worker/pdf.worker.min.js`;
const pdfPipeline = createPipeline(pdfjs, {}); const pdfPipeline = createPipeline(pdfjs, {});
export async function loadExample(progressListener: ProgressListenFunction): Promise<any> { export async function loadExample(progressListener: ProgressListenFunction): Promise<any> {
return parsePdf('/ExamplePdf.pdf', progressListener); return parsePdf('ExamplePdf.pdf', progressListener);
} }
export async function processUpload(file: File, progressListener: ProgressListenFunction): Promise<any> { export async function processUpload(file: File, progressListener: ProgressListenFunction): Promise<any> {