简体   繁体   中英

Webpack multiple entries output without “[name]” pattern

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.

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";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM