-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"ENOENT: no such file or directory" when trying to use image bundling #127
Comments
I have the same issue when trying to use esbuild-replace plugin to replace some strings in the .md file! Any support please? |
@chemicalkosek @Hartha-aloufi both use ---
title: First Post
---
import pic from './pic.png'
## This is a h2
This is my first post
<img src={pic} /> |
I experience the same issue. Also that each refresh creates a different @deadcoder0904 Tried your solution without luck, unfortunately. EDIT: After some testing, I came to a solution that works for me: const getCompiledMDX = async (source: string, slug: string) => {
try {
setEsbuildExecutable();
return await bundleMDX({
source,
cwd: path.join(BLOG_DIR, slug),
mdxOptions(options) {
options.remarkPlugins = [
...(options.remarkPlugins ?? []),
remarkMdxImages,
remarkAutolinkHeadings,
remarkSlug,
];
return options;
},
esbuildOptions: options => {
options.outdir = path.join(process.cwd(), 'public', 'images', slug);
options.publicPath = `/images/${slug}`;
options.write = true;
options.loader = {
...options.loader,
'.png': 'file',
'.jpeg': 'file',
'.jpg': 'file',
'.JPG': 'file',
};
return options;
},
});
} catch (error) {
throw error;
}
}; @chemicalkosek maybe this works for you as well 🤞 I used |
Hi. I'm having a problem bundling images. (Sorry upfront if it's wrong posting in issues, couldn't find any community. Enable Discussions maybe?)
I'm using Next.js
When trying to copy the images as per docs, I'm getting the following error when accessing the mdx page:
Server Error Error: ENOENT: no such file or directory, open '../../public/img/first-post/_mdx_bundler_entry_point-1bc7683e-0501-46a8-a3f9-58c40044932c.js'
On each refresh it creates another
_mdx_bundler_entry_point
with different hash. (?)My mdx setup:
The mdx file:
The image is actually copied with hash to the public folder:
What am I doing wrong? I have tried different configurations for
outdir
andpublicPath
with no luckThe text was updated successfully, but these errors were encountered: