Skip to content

interpolate: require doesn't handle "loader!" prefix #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fstanis opened this issue Oct 15, 2017 · 2 comments
Closed

interpolate: require doesn't handle "loader!" prefix #150

fstanis opened this issue Oct 15, 2017 · 2 comments

Comments

@fstanis
Copy link

fstanis commented Oct 15, 2017

I'm submitting a bug report

Webpack version:
3.7.1

HTML-Loader version:
0.4.5

Please tell us about your environment:
Linux

Current behavior:
html-loader's require (when interpolate=require is set) ignores a loader (e.g. file-loader!) I specify as prefix.

Expected/desired behavior:
Same as using require normally (parse any loaders before require-ing a file).

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

Given a HTML file with this:

<img src="${require('file-loader!./img.png')}">

Works with loader: 'html-loader?interpolate', fails with html-loader?interpolate=require - with the latter, ./ is prepended (I believe this is caused by loaderUtils.urlToRequest) and then webpack attempts to find ./file-loader!./img.png which fails (Module not found: Error: Can't resolve './file-loader').

  • What is the expected behavior?
    require behaving the same with interpolate and interpolate=require.
@Sawtaytoes
Copy link
Contributor

Sawtaytoes commented Jan 11, 2018

I created a fix for this when using require and will be creating a pull request soon. I alias my directories so having it put a ./ there because problematic as nowhere else in my code am I doing ../../../.

@michael-ciniawsky
Copy link
Member

Fixed in v0.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants