Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify Webpack instructions on cMaps and standard fonts
Browse files Browse the repository at this point in the history
wojtekmaj committed Jul 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent db43c90 commit e3d7000
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -242,24 +242,26 @@ Add `copy-webpack-plugin` to your project if you haven't already:
npm install copy-webpack-plugin --save-dev
```

Now, in your Webpack config, import the plugin:
Now, in your Webpack config, add the following:

```ts
import path from 'node:path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
```
```diff
+import path from 'node:path';
+import CopyWebpackPlugin from 'copy-webpack-plugin';

and in `plugins` section of your config, add the following:
+const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');

```ts
new CopyWebpackPlugin({
patterns: [
{
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
to: 'cmaps/'
},
module.exports = {
plugins: [
+ new CopyWebpackPlugin({
+ patterns: [
+ {
+ from: cMapsDir,
+ to: 'cmaps/'
+ },
+ ],
+ }),
],
}),
};
```

##### Other tools
@@ -335,22 +337,24 @@ npm install copy-webpack-plugin --save-dev

Now, in your Webpack config, import the plugin:

```ts
import path from 'node:path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
```
```diff
+import path from 'node:path';
+import CopyWebpackPlugin from 'copy-webpack-plugin';

and in `plugins` section of your config, add the following:
+const standardFontsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts');

```ts
new CopyWebpackPlugin({
patterns: [
{
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
to: 'standard_fonts/'
},
module.exports = {
plugins: [
+ new CopyWebpackPlugin({
+ patterns: [
+ {
+ from: standardFontsDir,
+ to: 'standard_fonts/'
+ },
+ ],
+ }),
],
}),
};
```

##### Other tools

0 comments on commit e3d7000

Please sign in to comment.