From fb43221ee46a5817e3c00b8db117199183877ba5 Mon Sep 17 00:00:00 2001
From: marekmitko <63197096+marekmitko@users.noreply.github.com>
Date: Fri, 21 May 2021 19:00:14 +0200
Subject: [PATCH] applied https://codesandbox.io/s/y4ev2?file=/package.json
from https://github.com/wojtekmaj/react-pdf/issues/136 result compiled
successfully
---
next.config.js | 23 +++++++++++++++++++
.../InvoicesGenerator/Components/Invoice.js | 4 ++--
pages/wystaw-fakture/index.js | 15 ++++++------
pdf-worker.js | 6 +++++
4 files changed, 38 insertions(+), 10 deletions(-)
create mode 100644 next.config.js
create mode 100644 pdf-worker.js
diff --git a/next.config.js b/next.config.js
new file mode 100644
index 0000000..972d231
--- /dev/null
+++ b/next.config.js
@@ -0,0 +1,23 @@
+module.exports = {
+ future: {
+ webpack5: true
+ },
+ webpack: (config) => {
+ // load worker files as a urls with `file-loader`
+ config.module.rules.unshift({
+ test: /pdf\.worker\.(min\.)?js/,
+ use: [
+ {
+ loader: "file-loader",
+ options: {
+ name: "[contenthash].[ext]",
+ publicPath: "_next/static/worker",
+ outputPath: "static/worker"
+ }
+ }
+ ]
+ });
+
+ return config;
+ }
+ };
diff --git a/pages/wystaw-fakture/InvoicesGenerator/Components/Invoice.js b/pages/wystaw-fakture/InvoicesGenerator/Components/Invoice.js
index e9b6ad0..9a3f4fc 100644
--- a/pages/wystaw-fakture/InvoicesGenerator/Components/Invoice.js
+++ b/pages/wystaw-fakture/InvoicesGenerator/Components/Invoice.js
@@ -29,12 +29,12 @@ const styles = StyleSheet.create({
const Invoice = ({invoice}) => (
-
+ {/*
-
+ */}
);
diff --git a/pages/wystaw-fakture/index.js b/pages/wystaw-fakture/index.js
index 594c520..42aa5d7 100644
--- a/pages/wystaw-fakture/index.js
+++ b/pages/wystaw-fakture/index.js
@@ -1,11 +1,10 @@
-import App from './InvoicesGenerator/App.js';
+import dynamic from "next/dynamic";
-export default function RenderUserDashboard() {
- return(
- <>
-
-
- >
- )
+const PDFViewer = dynamic(() => import("./InvoicesGenerator/App.js"), {
+ ssr: false
+});
+
+export default function PDF() {
+ return ;
}
\ No newline at end of file
diff --git a/pdf-worker.js b/pdf-worker.js
new file mode 100644
index 0000000..a913711
--- /dev/null
+++ b/pdf-worker.js
@@ -0,0 +1,6 @@
+if (process.env.NODE_ENV === "production") {
+ // use minified verion for production
+ module.exports = require("pdfjs-dist/build/pdf.worker.min.js");
+ } else {
+ module.exports = require("pdfjs-dist/build/pdf.worker.js");
+ }
\ No newline at end of file