willyelm / pug-html-loader

Pug HTML loader for webpack

Home Page:https://github.com/willyelm/pug-html-loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

require assets in pug file

mahpah opened this issue · comments

My question is how can I import assets in pug template?
In my pug file I have something like this

img(src=require('./path/to/file'))

But it throws 'require is not a function' error.

I've tried using with html-loader, use this config

{
        test: /\.jade/,
        loaders: [
          'html',
          'pug-html?pretty&' + JSON.stringify({ doctype: 'html' }),
        ],
}

Then I end up getting this error

Module not found: Error: Can't resolve './\"./path-to-file\"/' in 'path-to-folder'

But if I copy the pug-html output then using only html-loader, everything just work fine. Can anyone explain this to me? Thank you.

I've found this commit @54ed4724c6206b45e8e0db176ea9c65f355188ae worked. So downgrade to 1.0.7 fixed the issue. I don't know why you re-added JSON.stringify() in ver 1.0.8. Just leave a note here for people who facing the same issue.

why is this closed? its still an issue in the latest version?