Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…maj/react-pdf#136  result  compiled successfully
  • Loading branch information
marekmitko committed May 21, 2021
1 parent c7a2e47 commit fb43221
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
23 changes: 23 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
4 changes: 2 additions & 2 deletions pages/wystaw-fakture/InvoicesGenerator/Components/Invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const styles = StyleSheet.create({
const Invoice = ({invoice}) => (
<Document>
<Page size="A4" style={styles.page}>
<Image style={styles.logo} src={logo} />
{/* <Image style={styles.logo} src={logo} />
<InvoiceTitle title='Invoice'/>
<InvoiceNo invoice={invoice}/>
<BillTo invoice={invoice}/>
<InvoiceItemsTable invoice={invoice} />
<InvoiceThankYouMsg />
<InvoiceThankYouMsg /> */}
</Page>
</Document>
);
Expand Down
15 changes: 7 additions & 8 deletions pages/wystaw-fakture/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import App from './InvoicesGenerator/App.js';
import dynamic from "next/dynamic";

export default function RenderUserDashboard() {
return(
<>

<App />

</>
)
const PDFViewer = dynamic(() => import("./InvoicesGenerator/App.js"), {
ssr: false
});

export default function PDF() {
return <PDFViewer />;
}
6 changes: 6 additions & 0 deletions pdf-worker.js
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit fb43221

Please sign in to comment.