title: Require file emitted by webpack plugin through compilation.assets[] =
body: <p>I am using the <a href="https://github.com/odrick/webpack-free-tex-packer" rel="nofollow noreferrer">webpack-free-tex-packer</a> plugin to pack a bunch of images into atlases with these lines in <code>webpack.config.js</code>:</p>
  <pre class="lang-js prettyprint-override"><code>...
  plugins: [
      new WebpackFreeTexPacker(path.resolve(__dirname, 'textures'), 'atlases', {
          textureName: 'atlas',
          width: 512, height: 512,
          padding: 1,
          allowRotation: false, allowTrim: false,
          detectIdentical: true,
          exporter: &quot;Pixi&quot;,
      }),
  ],
  </code></pre>
  <p>which in turn emits the generated atlases <a href="https://github.com/odrick/webpack-free-tex-packer/blob/362a8ce861bf2581b126a048d4f6a58b69af3849/index.js#L172" rel="nofollow noreferrer">here</a> through setting properties on <code>compilation.assets</code>. This works and the outputs get shows up when building:</p>
  <pre><code>atlases/atlas-0.json   1.51 KiB          [emitted]
   atlases/atlas-0.png   32.6 KiB          [emitted]
  atlases/atlas-1.json  689 bytes          [emitted]
   atlases/atlas-1.png   3.03 KiB          [emitted]
  </code></pre>
  <p><strong>However how would I now go about importing the generated JSON files from a JavaScript module?</strong></p>
  <p>I have tried to do</p>
  <pre class="lang-js prettyprint-override"><code>const atlases = {};
  const r = require.context('../atlases/', false, /^atlas-\d+\.json$/);
  r.keys().forEach(key =&gt; atlases[key] = r(key));
  </code></pre>
  <p>(along with any other combination of import method and <code>'atlases/'</code> instead of the relative path), but I get the error</p>
  <pre><code>ERROR in ./src/main.js
  Module not found: Error: Can't resolve '../atlases/' in '/home/axel/git/project/src'
   @ ./src/main.js 38:8-66
  </code></pre>