Skip to content

Commit

Permalink
Fix vite-plugin-static-copy config not working on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jan 17, 2024
1 parent 7807060 commit 42eb211
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
14 changes: 12 additions & 2 deletions packages/react-pdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,15 @@ Add [`vite-plugin-static-copy`](https://www.npmjs.com/package/vite-plugin-static
```diff
+import path from 'node:path';
+import { createRequire } from 'node:module';

-import { defineConfig } from 'vite';
+import { defineConfig, normalizePath } from 'vite';
+import { viteStaticCopy } from 'vite-plugin-static-copy';

+const require = createRequire(import.meta.url);
+const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
+const cMapsDir = normalizePath(
+ path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps')
+);

export default defineConfig({
plugins: [
Expand Down Expand Up @@ -351,10 +356,15 @@ Add [`vite-plugin-static-copy`](https://www.npmjs.com/package/vite-plugin-static
```diff
+import path from 'node:path';
+import { createRequire } from 'node:module';

-import { defineConfig } from 'vite';
+import { defineConfig, normalizePath } from 'vite';
+import { viteStaticCopy } from 'vite-plugin-static-copy';

+const require = createRequire(import.meta.url);
+const standardFontsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts');
+const standardFontsDir = normalizePath(
+ path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts')
+);

export default defineConfig({
plugins: [
Expand Down
11 changes: 6 additions & 5 deletions sample/vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import path from 'node:path';
import { createRequire } from 'node:module';

import { defineConfig } from 'vite';
import { defineConfig, normalizePath } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';

const require = createRequire(import.meta.url);
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
const standardFontsDir = path.join(
path.dirname(require.resolve('pdfjs-dist/package.json')),
'standard_fonts',
const cMapsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
);
const standardFontsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
);

export default defineConfig({
Expand Down
11 changes: 6 additions & 5 deletions test/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import path from 'node:path';
import { createRequire } from 'node:module';

import { defineConfig } from 'vite';
import { defineConfig, normalizePath } from 'vite';
import react from '@vitejs/plugin-react';
import { viteStaticCopy } from 'vite-plugin-static-copy';

const require = createRequire(import.meta.url);
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps');
const standardFontsDir = path.join(
path.dirname(require.resolve('pdfjs-dist/package.json')),
'standard_fonts',
const cMapsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps'),
);
const standardFontsDir = normalizePath(
path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'standard_fonts'),
);

export default defineConfig({
Expand Down

0 comments on commit 42eb211

Please sign in to comment.