Webpack multiple entries output without "[name]" pattern

130 Views Asked by At

I want to determine the file name output without the [name] string pattern. I have multiple entries and want to determine the file name by logic which uses the Entry. Something like this:

output: {
        path: getFilePath(),
        filename: getFileName(),
    },

The problem is the entry is not known when I run the webpack config.

1

There are 1 best solutions below

0
Nisim Joseph On

I checked in the Webpack multiple entries docs and didn't find any way to do it.

Then, I found when you give the filename a function, not running it like here:

output: {
        path: getFilePath(),
        filename: getFileName,
    },

The Webpack will call this function with an Entry argument and it will contain the entry it running now, for example:

    function getFileName(entry) {
    if (entry.chunk.name === "name1") {
        return "Test1";
    }
    return "Test2";
}