extract-loader icon indicating copy to clipboard operation
extract-loader copied to clipboard

[help] issues with html-loader interpolation

Open zacharyrs opened this issue 6 years ago • 3 comments

Hi,

I'm in the works of developing my own static site generator that relies on pug templates, and markdown content.

I use webpack to bundle the precompiled pug (i.e. html) files, along with css+js, and also to process images etc.

I'm facing an issue using html-interpolation, such that the output bundle has undefined for image sources etc.

For reference, the compiled HTML looks as such:

...
    <script src="${require('../../base/templates/index.sss')}"></script>
...
            <span class="image-wrapper">
                <img class="image-preview" src=${require('../../content/pages/res/mini.jpg').preview} alt="test" title="sss">
                <img class="image-main" onload="this.classList.add('image-loaded')" src=${require('../../content/pages/res/mini.jpg').src} srcset=${require('../../content/pages/res/mini.jpg').srcSet} alt="test" title="sss">
            </span>
...

Webpack does include and process the required images, however the output HTML is as such:

...
    <script src="[object Object]"></script>
...
            <span class="image-wrapper">
                <img class="image-preview" src=undefined alt="test" title="sss">
                <img class="image-main" onload="this.classList.add('image-loaded')" src=undefined srcset=undefined alt="test" title="sss">
            </span>
...

The css interpolated require also appears to have issues, but this may be at my own fault.

The repo may be found here: https://github.com/zacharyrs/ssg.z

Hopefully someone can see where I'm going wrong, or if this is at fault of extract-loader.

Thanks, Zach

zacharyrs avatar Jan 13 '19 12:01 zacharyrs

Probably related to #54.

zacharyrs avatar Jan 15 '19 22:01 zacharyrs

@zacharyrs can you verify that the latest changes fixed this issue?

jannikkeye avatar May 26 '20 07:05 jannikkeye

I'm a little busy with uni at the moment, but I'll check it ASAP in the next couple of weeks!

zacharyrs avatar May 26 '20 12:05 zacharyrs