Skip to content

Commit

Permalink
Add copy-cmaps script to Parcel and Parcel 2 samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jan 19, 2022
1 parent 6bb29a9 commit 230fd89
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions sample/parcel/package.json
Expand Up @@ -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"
},
Expand Down
16 changes: 16 additions & 0 deletions 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));
});
1 change: 1 addition & 0 deletions sample/parcel2/package.json
Expand Up @@ -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"
},
Expand Down
16 changes: 16 additions & 0 deletions 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));
});

0 comments on commit 230fd89

Please sign in to comment.