Fix react-pdf for prod build #15
21
public/pdf.worker.min.mjs
Normal file
21
public/pdf.worker.min.mjs
Normal file
File diff suppressed because one or more lines are too long
@ -3,11 +3,8 @@ import { Document, Page, pdfjs } from 'react-pdf';
|
||||
|
||||
import { Typography } from '@mui/material';
|
||||
|
||||
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#import-worker-recommended
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
||||
'pdfjs-dist/build/pdf.worker.min.mjs',
|
||||
import.meta.url,
|
||||
).toString();
|
||||
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#copy-worker-to-public-directory
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.min.mjs'
|
||||
|
||||
const TermsAndConditionsBox = ({height}: {height: string}) => {
|
||||
const [numPages, setNumPages] = useState<number>();
|
||||
@ -30,7 +27,10 @@ const TermsAndConditionsBox = ({height}: {height: string}) => {
|
||||
alignItems: 'center'
|
||||
}}
|
||||
>
|
||||
<Document file='/TermsAndConditions.pdf' onLoadSuccess={onDocumentLoadSuccess}>
|
||||
<Document
|
||||
file={process.env.PUBLIC_URL + '/TermsAndConditions.pdf'}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
>
|
||||
{Array.apply(null, Array(numPages))
|
||||
.map((x, i) => i + 1)
|
||||
.map((page) => {
|
||||
|
@ -13,7 +13,7 @@ const TermsAndConditionsDialog: React.FC<TermsDialogProps> = ({ open, onClose })
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} maxWidth="lg">
|
||||
<DialogContent>
|
||||
<TermsAndConditionsBox height='75vh' />
|
||||
<TermsAndConditionsBox height='65vh' />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} color="primary">
|
||||
|
Loading…
Reference in New Issue
Block a user