Search code examples
javascriptwebpack-2source-maps

Sourcemap from multiple bundles


I have a main app foo with webpack2 which bundles some node_modules. One of the module is a bar which is also bundled with webpack2 with sourcemaps.

I used to have bar bundle injected into foo index.html as a separate script and sourcemaps were working fine in devtools.

Now foo is bundling bar and other node_modules together into a vendor bundle and that gets injected into index.html. In devtools I can see only the whole vendor bundle with sourcemap for all libraries.

Is there a way of having my bar bundle sourcemap appended somehow so I could treat that bundle separately and see the folder structure in devtools?

With current setup I can see in devtools only bar.bundle.js but I would like to see more granular like I had initially.


Solution

  • This loader seems to do the trick!

    rules: [{
      test: /\.js$/,
      use: ['source-map-loader'],
      enforce: 'pre',
    },