From 0e4346246e55f1a7a1ad5a842e1cffdd446e7b14 Mon Sep 17 00:00:00 2001 From: Damian Cyntler Date: Fri, 28 Jun 2024 22:17:50 +0200 Subject: [PATCH] chore: add copy-worker script --- package.json | 2 +- scripts/copy-worker.mjs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/copy-worker.mjs diff --git a/package.json b/package.json index a23f3bc..12e6dbc 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "prettier:fix": "prettier --write .", "storybook:build": "rm -rf storybook-static && storybook build", "deploy": "npm run storybook:build && gh-pages --nojekyll -d storybook-static --message 'feat: storybook deploy'", - "prerelease": "git checkout main && git pull && npm run prettier:check && npm run lint && npm run test && npm run build && cd use-cases/nextjs && npm i && npm run build", + "prerelease": "git checkout main && git pull && npm run prettier:check && npm run lint && npm run test && npm run build && cd use-cases/nextjs && npm i && npm run build && node ./scripts/copy-worker.mjs", "release": "release-it && npm run deploy", "build-readme-toc": "npx doctoc README.md --title '## Table of Contents'", "prepublish": "npm run build-readme-toc" diff --git a/scripts/copy-worker.mjs b/scripts/copy-worker.mjs new file mode 100644 index 0000000..e7ef020 --- /dev/null +++ b/scripts/copy-worker.mjs @@ -0,0 +1,10 @@ +import path from "node:path"; +import fs from "node:fs"; +import { createRequire } from "node:module"; + +const require = createRequire(import.meta.url); + +const pdfjsDistPath = path.dirname(require.resolve("pdfjs-dist/package.json")); +const pdfWorkerPath = path.join(pdfjsDistPath, "build", "pdf.worker.mjs"); + +fs.copyFileSync(pdfWorkerPath, "./dist/pdf.worker.mjs");