question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Copy images in `docs` directory into production build

See original GitHub issue

🐛 Bug Report

When a markdown file refers to an image in the current directory, it will render correctly when the dev server is running. However, the production build will not include the image (they are not copied from docs to build).

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Add an image to the docs directory and reference it from a markdown file:

My image:

![](image1.png)

Under the dev server, image1.png will show up. But in a production build it will be a broken link.

Expected behavior

I would expect image1.png to show up at build\docs\image1.png.

Actual Behavior

The image does not appear and the link is broken in the rendered markdown.

Your Environment

Windows 10, running node 14, with docusaurus 2.0.0-alpha.56.

Reproducible Demo

The repo at https://github.com/jbaileyashe/docusaurus-bug demonstrates the problem. The file docs\bug.md refers to an image in that directory (bug.png).

Under the development server (npm run start), the image shows up:

image

However, the production build will not include bug.png. After npm run build, running serve -s build -l 3000 (which serves those files through a simple webserver), you can see that the image is missing:

image

I checked in the build directory. Looking in build\docs\bug, there is no bug.png, even though index.html in that directory refers to it.

Ideally, bug.png would get copied to build\docs\bug.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jbaileyashecommented, Jun 18, 2020

I think there is a plugin or configuration problem. When I try that, I get a compilation error:

./docs/bug.png 1:0
Module parse failed: Unexpected character '�' (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)
 @ ./docs/bug.mdx 1:1088-1108
 @ ./.docusaurus/registry.js
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js

If that worked though, it’d be a totally acceptable solution.

1reaction
slorbercommented, Jul 24, 2020

Hey all, this is feature is now released! If you like it, don’t forget to retweet 😄 https://twitter.com/docusaurus/status/1286715187983048704

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a simple method to copy an image from Google Docs ...
Triple-click the image (or Select All) to select it and then you can right-click it and "Copy Image". Then you can paste it...
Read more >
Organize your files in Google Drive - Computer
On your computer, go to drive.google.com. Select a file. Select an option: To copy the file or folder name to the clipboard as...
Read more >
7 Ways to Save an Image From Google Docs - Online Tech Tips
Here's how to go about it: Open the document in the Google Docs app. Long-press the image you want to save, release your...
Read more >
Adding Images to Google Docs - 3 Easy Ways - YouTube
Explore several different ways to add images to your Google Docs.
Read more >
Best practices for writing Dockerfiles - Docker Documentation
This document covers recommended best practices and methods for building efficient images. Docker builds images automatically by reading the instructions from a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found