I have a pug mixin for review block. Adding review, I pass what image I wanna use as a profile avatar and so I need to load it on the fly. Let's simplify code to just loading an image.
mixin image({src=""} = {})
.image
- var imageSRC = "./images/" + src + ".jpg";
img(src=require(imageSRC))
The problem is I must use relative path in require function, because mixin can be used not on single page.
I've read pug documentation so I understand that there's problem with wepback, because it searches in bundled dist
folder (where all project is bundling). So I have to set something in webpack configuration. Currently I load pug simply using pug-loader.
module: {
rules: [
...
{
test: /\.pug$/,
loader: "pug-loader"
}
...
]
}
I guess there is some plugin or extra option but I haven't found one. Perfect result for me is to get an image in base64 format.