Skip to content

Allow output.filename to be a function #3483

@janmeier

Description

@janmeier

What problem does this feature solve?

Webpack supports passing a function to output.filename, to be able to dynamically determine the output filename of an entry point.

In our case we are including some entries automagically using the builtins.html so we would like to include [contenthash] in the file name, but other bundles are being consumed by external scripts, so we would like to keep the output name static.

What does the proposed API of configuration look like?

From https://webpack.js.org/configuration/output/#outputfilename

module.exports = {
  //...
  output: {
    filename: (pathData) => {
      return pathData.chunk.name === 'main' ? '[name].js' : '[name]/[name].js';
    },
  },
};

Metadata

Metadata

Assignees

Labels

featNew feature or requestgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions