Different image paths between dev and prod for vue require

Viewed 70

I have the following architecture:

ProjectName
  - dist
    - img
    - index.html
  - src
    - assets
      - fonts
      - img
  - public
      - img

I save static images in ProjectName/src/assets/img/

And save dynamic images (images that user uploaded) in public folder with path ProjectName/public/img from my Flask backend. I'm doing this because I want to get image on the fly without use webpack build

So, I can view images in developer mode use

return require('../../public/img/paintings/'+imgName)

But when I use production mode I must write without first ../

return require('../public/img/paintings/'+imgName)

Because dist folder has shorter path to public folder than non build project

How I come to agreement with different paths and don't change code before build?

1 Answers
Related