Search code examples
javascriptwebpackincluderequirepartials

How to include html partials with webpack (version 2) with the html-loader?


I am working hard to include a simple footer.html, as an html partial) via html-loader. I am using webpack version 2.

I failed trying to use ${require('**./footer.html**')} and ${require('**../footer.html**')}.

I am not using ejs loader and I do not use the handlebar plugin.

Does somebody know how I can fix this problem and whether it possible to render partials with webpack.

Thanks for your advice!


Solution

  • The feature is called interpolation. Here { test: /\.html$/, use: ['html-loader?interpolate'] }, is a webpack configuration rule that leverages it by specifying the interpolate flag.