Require variable with HTML Webpack Plugin
<p>based on this Example (<a href="https://github.com/ampedandwired/html-webpack-plugin/tree/master/examples/custom-template" rel="nofollow">https://github.com/ampedandwired/html-webpack-plugin/tree/master/examples/custom-template</a>) I created an similar setup which requires the sub html file via an environment var.</p>

<pre><code>function generate_page(config) {
    var tempateUrl = config.templateUrl ? config.templateUrl : 'src/template.html';
    return new HtmlWebpackPlugin({
        filename:  config.filename,
        template: tempateUrl,
        xhtml: true,
        environment: {templateUrl:  config. subTemplateUrl}
    });

}
</code></pre>

<p>My src/template.html requires this subtemplate:</p>

<pre><code>&lt;!doctype html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;% require('html!'+ htmlWebpackPlugin.options.environment.templateUrl ) %&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>But when I run <code>webpack  --progress --colors --watch -d</code> I just get that error:</p>

<pre><code>ERROR in Template execution failed: Error: Cannot find module "."

ERROR in   Error: Cannot find module "."

  - template.html:57 webpackMissingModule
    /Users/xxx/PycharmProjects/webpack-test/src/template.html:57:47

  - template.html:57 
    /Users/xxx/PycharmProjects/webpack-test/src/template.html:57:125

  - template.html:62 module.exports
    /Users/xxx/PycharmProjects/webpack-test/src/template.html:62:4

  - index.js:228 
    [webpack-test]/[html-webpack-plugin]/index.js:228:16

  - util.js:16 tryCatcher
    [webpack-test]/[bluebird]/js/release/util.js:16:23

  - promise.js:503 Promise._settlePromiseFromHandler
    [webpack-test]/[bluebird]/js/release/promise.js:503:31

  - promise.js:560 Promise._settlePromise
    [webpack-test]/[bluebird]/js/release/promise.js:560:18

  - promise.js:597 Promise._settlePromiseCtx
    [webpack-test]/[bluebird]/js/release/promise.js:597:10

  - async.js:131 Async._drainQueue
    [webpack-test]/[bluebird]/js/release/async.js:131:12

  - async.js:136 Async._drainQueues
    [webpack-test]/[bluebird]/js/release/async.js:136:10
</code></pre>

<p>If I write the same subTemplateUrl in the template.html file instead of the variable everything works fine:</p>

<pre><code>&lt;% require('html!./test.html' ) %&gt;
</code></pre>