Mdx-deck: Question: how to bundle assets like images in build?

Created on 26 Aug 2018  路  4Comments  路  Source: jxnblk/mdx-deck

I added a static/ directory to put offline assets in like images. Then I use them like:

import { Image } from "mdx-deck"

<Image src="./static/thing.gif" />

This works with mdx-deck (dev mode), and mdx-deck pdf, but not mdx-deck build. Is there a good way to include offline static assets with builds?

Most helpful comment

I use it like this:

<img src={require("file-loader!./somthing.png")}/>

All 4 comments

My current workaround is to copy my static/ folder in npm scripts:

    "build": "npm run clean && npm run static && npm run html && npm run pdf",
    "clean": "rm -rf docs",
    "static": "mkdir -p docs/static && cp -R src/static docs/",
    "html": "mdx-deck build src/index.mdx -d docs",
    "pdf": "mdx-deck pdf src/index.mdx -d docs",

Then npm run build gives me everything I need to host the presentation.

I use it like this:

<img src={require("file-loader!./somthing.png")}/>

Any plans to support ![](../static/foo.gif)?

I use it like this:

<img src={require("file-loader!./somthing.png")}/>

I get a Uncaught ReferenceError: require is not defined using this technique to load images in dev mode.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codepunkt picture codepunkt  路  5Comments

kwangkim picture kwangkim  路  4Comments

dance2die picture dance2die  路  5Comments

wesbos picture wesbos  路  6Comments

janhesters picture janhesters  路  3Comments