Skip to content

Commit e3d7000

Browse files
committed
Simplify Webpack instructions on cMaps and standard fonts
1 parent db43c90 commit e3d7000

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -242,24 +242,26 @@ Add `copy-webpack-plugin` to your project if you haven't already:
242242
npm install copy-webpack-plugin --save-dev
243243
```
244244

245-
Now, in your Webpack config, import the plugin:
245+
Now, in your Webpack config, add the following:
246246

247-
```ts
248-
import path from 'node:path';
249-
import CopyWebpackPlugin from 'copy-webpack-plugin';
250-
```
247+
```diff
248+
+import path from 'node:path';
249+
+import CopyWebpackPlugin from 'copy-webpack-plugin';
251250

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

254-
```ts
255-
new CopyWebpackPlugin({
256-
patterns: [
257-
{
258-
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
259-
to: 'cmaps/'
260-
},
253+
module.exports = {
254+
plugins: [
255+
+ new CopyWebpackPlugin({
256+
+ patterns: [
257+
+ {
258+
+ from: cMapsDir,
259+
+ to: 'cmaps/'
260+
+ },
261+
+ ],
262+
+ }),
261263
],
262-
}),
264+
};
263265
```
264266

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

336338
Now, in your Webpack config, import the plugin:
337339

338-
```ts
339-
import path from 'node:path';
340-
import CopyWebpackPlugin from 'copy-webpack-plugin';
341-
```
340+
```diff
341+
+import path from 'node:path';
342+
+import CopyWebpackPlugin from 'copy-webpack-plugin';
342343

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

345-
```ts
346-
new CopyWebpackPlugin({
347-
patterns: [
348-
{
349-
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
350-
to: 'standard_fonts/'
351-
},
346+
module.exports = {
347+
plugins: [
348+
+ new CopyWebpackPlugin({
349+
+ patterns: [
350+
+ {
351+
+ from: standardFontsDir,
352+
+ to: 'standard_fonts/'
353+
+ },
354+
+ ],
355+
+ }),
352356
],
353-
}),
357+
};
354358
```
355359

356360
##### Other tools

0 commit comments

Comments
 (0)