You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After study, I find this is a questions about webpack. When require a dynamic file path, we must indicate the file extension literally. It works in this way:
- var url = './image/xxxx'
img(src=require(url + './png'), width='150px')
@njleonzhang You found a workaround but what you said is not the cause. The thing that made your require call work is the creation of a context and not the addition of the file extension.
Instead of using the #{} syntax, we have to use the attribute interpolation syntax.
As i described in #122 (comment), we can use string casting to pass a variable when calling require so as create a dynamic require context.
is there a method which I can require resource from a pug variable?
error:
The text was updated successfully, but these errors were encountered: