Skip to content

Commit

Permalink
Simplify Webpack instructions on cMaps and standard fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jul 21, 2023
1 parent db43c90 commit e3d7000
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e3d7000

Please sign in to comment.