webpackpartialhtml-webpack-pluginwebpack-html-loader

Webpack: include html partial inside another partial?


Is there a way to include html partial inside another partial using webpack? I am using html-loader to do this:

index.html

<%= require('html-loader!./partials/_header.html') %>

But when I try to include another partial inside a _header.html it is not able to render it.

This is not working:

_header.html

<%= require('html-loader!./partials/_nav.html') %>

Solution

  • I was combining a little and I was able to find a solution.

    index.html

    <%= require('html-loader?root=.&minimize=true&interpolate!./partials/_header.html') %>
    

    and then in _header.html

    ${require('html-loader?root=.!../partials/_nav.html')}