doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.6k stars 1.46k forks source link

Images with absolute path do not work #1606

Open BrianSidebotham opened 3 years ago

BrianSidebotham commented 3 years ago

Bug Report

Describe the bug

As per the documentation for the public settting an example is shown for the public setting and how it may be used to get images:

export default {
  public: '/public'
}

Then you can get assets from your folder:

// my-file.mdx
# Hello

![placeholder image](/public/some-image.png)

This doesn't work. The bug is along the lines:

ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve './/public/tux.png' in 'my-docz-app/src'

If you're trying to use a package make sure that './/public/tux.png' is installed. If you're trying to use a local file make sure that the path is correct.

File: ../src/index.mdx

To Reproduce

npx create-docz-app my-docz-app --example images && cd my-docz-app
  1. Change src/index.mdx images to absolute image references
![Tux](/public/tux.png)
  1. Run yarn dev

Observe build error

Expected behavior

The same rendered output as the images example using relative file references.

Environment

$ cat package.json 
{
  "private": true,
  "name": "docz-example-images",
  "version": "2.0.0-rc.41",
  "license": "MIT",
  "files": [
    "src/",
    "doczrc.js",
    "package.json"
  ],
  "scripts": {
    "dev": "docz dev",
    "build": "docz build"
  },
  "dependencies": {
    "@emotion/react": "^11.1.1",
    "@emotion/styled": "^11.0.0",
    "docz": "latest",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6"
  }
}
$ node --version
v15.7.0