<p dir="auto"><strong>How to get the current entry point's name from within a loader?</strong></p>
<p dir="auto">It is needed for a customized <code class="notranslate">file-loader</code> that uses <code class="notranslate">loaderUtils.interpolateName</code> by default which obviously interpolates the <code class="notranslate">[name]</code> to the currently required file name.</p>
<p dir="auto">In <code class="notranslate">extract-text-webpack-plugin</code> the <code class="notranslate">[name]</code> is interpolated to the <strong>entry point name</strong> and that's what I'm for in the customized <code class="notranslate">file-loader</code> <em>(the purpose of which is to aid in toggling source-maps for <code class="notranslate">.less</code> files depending on current environment)</em></p>
<p dir="auto">Hence the question. Thanks.</p>
<p dir="auto">If I have a entry <code class="notranslate">hello.js</code> like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="require('./images/test.png');"><pre class="notranslate"><code class="notranslate">require('./images/test.png');
</code></pre></div>
<p dir="auto">and I use <code class="notranslate">file-loader</code> to handle this, then I want the built image named as "hello.test.png",how can I make it?</p>
<p dir="auto">The following example can not fill my need:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  test: /\.(jpe?g|png|gif|svg)$/i,
  loaders: ['file?hash=sha512&amp;digest=hex&amp;name=[path][hash].[ext]']
}"><pre class="notranslate"><code class="notranslate">{
  test: /\.(jpe?g|png|gif|svg)$/i,
  loaders: ['file?hash=sha512&amp;digest=hex&amp;name=[path][hash].[ext]']
}
</code></pre></div>