shellscape / webpack-manifest-plugin

webpack plugin for generating asset manifests
MIT License
1.44k stars 185 forks source link

Only one manifest is emitted when used in multiple configurations #147

Closed uhyo closed 6 years ago

uhyo commented 6 years ago

Thank you for the great plugin!

When it is used multiple times in multiple (array) webpack configurations, only one manifest is emitted.

webpack and webpack-manifest-plugin version:

Reproduction: webpack.config.js

const path = require('path');
const ManifestPlugin = require('webpack-manifest-plugin');

const config1 = {
    mode: 'development',
    entry: {
        entry1: './src/entry1.js',
    },
    output: {
        path: path.join(__dirname, './dist1'),
    },
    plugins: [
        new ManifestPlugin(),
    ],
}; 

const config2 = {
    mode: 'development',
    entry: {
        entry2: './src/entry2.js',
    },
    output: {
        path: path.join(__dirname, './dist2'),
    }, 
    plugins: [
        new ManifestPlugin(),
    ],
}; 

module.exports = [config1, config2];

When we run this we expect dist1/manifest.json and dist2/manifest.json to be emitted, but actually we get only dist2/manifest.json.

A workaround is to use different file names for each configuration, as in:

// in config1
new ManifestPlugin({
  fileName: 'manifest1.json',
})
// in config2
new ManifestPlugin({
  fileName: 'manifest2.json',
})

Thanks.

mastilver commented 6 years ago

Related #146

mastilver commented 6 years ago

Thank you for the detailed issue!

I believe it was introduced by: https://github.com/danethurber/webpack-manifest-plugin/pull/134

I didn't have time yet to do any further investigation. Feel free to submit a PR if you have a solution ;)

dschoschu commented 6 years ago

I can confirm the bug and that the change from #146 fixes it.

uhyo commented 6 years ago

Thanks for reply. I searched for issues but missed the related pull request. Sorry about that.

mastilver commented 6 years ago

fixed on v2.0.2