Skip to content

Commit 265fd34

Browse files
committed
Make instructions for copying cMaps work with Yarn PnP, update sample and test suites
1 parent b826f2e commit 265fd34

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ npm install copy-webpack-plugin --save-dev
173173
Now, in your Webpack config, import the plugin:
174174

175175
```js
176+
import path from 'path';
176177
import CopyWebpackPlugin from 'copy-webpack-plugin';
177178
```
178179

@@ -181,7 +182,7 @@ and in `plugins` section of your config, add the following:
181182
```js
182183
new CopyWebpackPlugin([
183184
{
184-
from: 'node_modules/pdfjs-dist/cmaps/',
185+
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
185186
to: 'cmaps/'
186187
},
187188
]),

sample/webpack4/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
66

77
const isProduction = process.env.NODE_ENV === 'production';
88

9+
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
10+
911
module.exports = {
1012
mode: isProduction ? 'production' : 'development',
1113
bail: isProduction,
@@ -56,7 +58,7 @@ module.exports = {
5658
new CopyWebpackPlugin({
5759
patterns: [
5860
{ from: './sample.pdf' },
59-
{ from: 'node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
61+
{ from: cMapsDir, to: 'cmaps/' },
6062
],
6163
}),
6264
],

sample/webpack5/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
66

77
const isProduction = process.env.NODE_ENV === 'production';
88

9+
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
10+
911
module.exports = {
1012
mode: isProduction ? 'production' : 'development',
1113
bail: isProduction,
@@ -56,7 +58,7 @@ module.exports = {
5658
new CopyWebpackPlugin({
5759
patterns: [
5860
{ from: './sample.pdf' },
59-
{ from: 'node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
61+
{ from: cMapsDir, to: 'cmaps/' },
6062
],
6163
}),
6264
],

test/webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'
88
const isProduction = process.env.NODE_ENV === 'production';
99
const isDevelopment = !isProduction;
1010

11+
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
12+
1113
module.exports = {
1214
mode: isProduction ? 'production' : 'development',
1315
bail: isProduction,
@@ -67,7 +69,7 @@ module.exports = {
6769
new CopyWebpackPlugin({
6870
patterns: [
6971
'test.pdf',
70-
{ from: '../node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
72+
{ from: cMapsDir, to: 'cmaps/' },
7173
],
7274
}),
7375
new HtmlWebpackPlugin({

0 commit comments

Comments
 (0)