I am building a portfolio site and want to add a button to download my resume. The pdf file is in the /public/resume.pdf . I want to import the file to a react component where I can the traditional <a href=ResumePDF download>Download the resume</a>
. I’m having this error:
./public/resume.pdf
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
I assume I’ve to change the next config file, but don’t know that. Please advice…
Edit:
This is my current next config file (next.config.mjs since I’ve mdx config )-
import remarkGfm from 'remark-gfm'
import createMDX from '@next/mdx'
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
}
const withMDX = createMDX({
options: {
remarkPlugins: [remarkGfm],
rehypePlugins: [],
},
})
// Merge MDX config with Next.js config
export default withMDX(nextConfig)
2
Answers
Downloaded the file loader npm package and changed the config file as shown...
Let me know if this helps
This works for me, you need add some loaders to the next.config.js
Daniel