EmilTholin/image-trace-loader

How to do image dynamic import?

pogran opened this issue · 1 comments

It's my code

const {book} = this.props
const urlImage = `../../../../..${book.image}`
const image = require(urlImage)

I can next issue http://prntscr.com/hsknvf .
Uncaught Error: Cannot find module "."
at webpackMissingModule

How i can to do dynamic import?

Hi @pogran! Webpack doesn't work like that, sadly. Your image import has to be static so it can be imported at build time, not at run time.