diff --git a/sample/parcel/package.json b/sample/parcel/package.json index cae921ffb..8e4de4c94 100644 --- a/sample/parcel/package.json +++ b/sample/parcel/package.json @@ -4,6 +4,7 @@ "description": "A sample page for React-PDF.", "private": true, "scripts": { + "copy-cmaps": "node ./scripts/copy-cmaps.js", "build": "parcel build index.html --public-url ./", "start": "parcel index.html" }, diff --git a/sample/parcel/scripts/copy-cmaps.js b/sample/parcel/scripts/copy-cmaps.js new file mode 100644 index 000000000..7b8ae13e4 --- /dev/null +++ b/sample/parcel/scripts/copy-cmaps.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + +const pdfjsDistPath = path.dirname(require.resolve('pdfjs-dist/package.json')); +const sourceDir = path.join(pdfjsDistPath, 'cmaps'); + +const targetDir = path.join('dist', 'cmaps'); + +// Ensure target directory exists +fs.mkdirSync(targetDir, { recursive: true }); + +// Copy all files from the source directory to the target directory +const files = fs.readdirSync(sourceDir); +files.forEach((file) => { + fs.copyFileSync(path.join(sourceDir, file), path.join(targetDir, file)); +}); diff --git a/sample/parcel2/package.json b/sample/parcel2/package.json index d761035c5..a105b62ba 100644 --- a/sample/parcel2/package.json +++ b/sample/parcel2/package.json @@ -4,6 +4,7 @@ "description": "A sample page for React-PDF.", "private": true, "scripts": { + "copy-cmaps": "node ./scripts/copy-cmaps.js", "build": "parcel build index.html --public-url ./", "start": "parcel index.html" }, diff --git a/sample/parcel2/scripts/copy-cmaps.js b/sample/parcel2/scripts/copy-cmaps.js new file mode 100644 index 000000000..7b8ae13e4 --- /dev/null +++ b/sample/parcel2/scripts/copy-cmaps.js @@ -0,0 +1,16 @@ +const fs = require('fs'); +const path = require('path'); + +const pdfjsDistPath = path.dirname(require.resolve('pdfjs-dist/package.json')); +const sourceDir = path.join(pdfjsDistPath, 'cmaps'); + +const targetDir = path.join('dist', 'cmaps'); + +// Ensure target directory exists +fs.mkdirSync(targetDir, { recursive: true }); + +// Copy all files from the source directory to the target directory +const files = fs.readdirSync(sourceDir); +files.forEach((file) => { + fs.copyFileSync(path.join(sourceDir, file), path.join(targetDir, file)); +});