Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack 4 pug loader image url not correct

according to the doc of pug loader

Embedded resources

Try to use require for all your embedded resources, to process them with webpack.

div
  img(src=require("./my/image.png"))

and it looks working with me the terminal emitted my image and no error

But the url path not correct

the code:

div.phone-container
    h1 
        a
            img(src=require('./../../assets/images/logo-sm.png'))
    .hamburger.hamburger--collapse
        .hamburger-box
            .hamburger-inner

Produce this weird url object : enter image description here

like image 771
Ayman Morsy Avatar asked Sep 16 '25 20:09

Ayman Morsy


1 Answers

Since require function return object - I don't know why -. I tried to extract the value using .default and It works this is my code :

div.phone-container
    h1 
        a
            img(src=require('./../../assets/images/logo-sm.png').default)
    .hamburger.hamburger--collapse
        .hamburger-box
            .hamburger-inner
like image 113
Ayman Morsy Avatar answered Sep 19 '25 12:09

Ayman Morsy