Skip to content

Commit

Permalink
Make instructions for copying cMaps work with Yarn PnP, update sample…
Browse files Browse the repository at this point in the history
… and test suites
  • Loading branch information
wojtekmaj committed Jan 5, 2022
1 parent b826f2e commit 265fd34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -173,6 +173,7 @@ npm install copy-webpack-plugin --save-dev
Now, in your Webpack config, import the plugin:

```js
import path from 'path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
```

Expand All @@ -181,7 +182,7 @@ and in `plugins` section of your config, add the following:
```js
new CopyWebpackPlugin([
{
from: 'node_modules/pdfjs-dist/cmaps/',
from: path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
to: 'cmaps/'
},
]),
Expand Down
4 changes: 3 additions & 1 deletion sample/webpack4/webpack.config.js
Expand Up @@ -6,6 +6,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');

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

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

module.exports = {
mode: isProduction ? 'production' : 'development',
bail: isProduction,
Expand Down Expand Up @@ -56,7 +58,7 @@ module.exports = {
new CopyWebpackPlugin({
patterns: [
{ from: './sample.pdf' },
{ from: 'node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
{ from: cMapsDir, to: 'cmaps/' },
],
}),
],
Expand Down
4 changes: 3 additions & 1 deletion sample/webpack5/webpack.config.js
Expand Up @@ -6,6 +6,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');

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

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

module.exports = {
mode: isProduction ? 'production' : 'development',
bail: isProduction,
Expand Down Expand Up @@ -56,7 +58,7 @@ module.exports = {
new CopyWebpackPlugin({
patterns: [
{ from: './sample.pdf' },
{ from: 'node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
{ from: cMapsDir, to: 'cmaps/' },
],
}),
],
Expand Down
4 changes: 3 additions & 1 deletion test/webpack.config.js
Expand Up @@ -8,6 +8,8 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'
const isProduction = process.env.NODE_ENV === 'production';
const isDevelopment = !isProduction;

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

module.exports = {
mode: isProduction ? 'production' : 'development',
bail: isProduction,
Expand Down Expand Up @@ -67,7 +69,7 @@ module.exports = {
new CopyWebpackPlugin({
patterns: [
'test.pdf',
{ from: '../node_modules/pdfjs-dist/cmaps/', to: 'cmaps/' },
{ from: cMapsDir, to: 'cmaps/' },
],
}),
new HtmlWebpackPlugin({
Expand Down

0 comments on commit 265fd34

Please sign in to comment.