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 40e5b3c commit 10ddf61
Show file tree
Hide file tree
Showing 4 changed files with 36 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
17 changes: 17 additions & 0 deletions sample/parcel/scripts/copy-cmaps.js
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');

function copyDir(from, to) {
// Ensure target directory exists
fs.mkdirSync(to, { recursive: true });

const files = fs.readdirSync(from);
files.forEach((file) => {
fs.copyFileSync(path.join(from, file), path.join(to, file));
});
}

const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
const targetDir = path.join('dist', 'cmaps');

copyDir(cMapsDir, targetDir);
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
17 changes: 17 additions & 0 deletions sample/parcel2/scripts/copy-cmaps.js
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');

function copyDir(from, to) {
// Ensure target directory exists
fs.mkdirSync(to, { recursive: true });

const files = fs.readdirSync(from);
files.forEach((file) => {
fs.copyFileSync(path.join(from, file), path.join(to, file));
});
}

const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
const targetDir = path.join('dist', 'cmaps');

copyDir(cMapsDir, targetDir);

0 comments on commit 10ddf61

Please sign in to comment.