Skip to content

[Bug]: license-webpack-plugin will not replace "[name]" in "outputFilename" #7960

@Agritite

Description

@Agritite

System Info

@rspack/core: 1.0.5
license-webpack-plugin: 4.0.2

Details

The default value for outputFilename in license-webpack-plugin is '[name].licenses.txt';
however, perChunkOutput enabled or not, the '[name]' will not be replaced at all, resulting in
license-webpack-plugin to only generate one [name].licenses.txt[sic] file and just keep overwriting it.

I did some debugging,

https://github.com/xz64/license-webpack-plugin/blob/32bf7a4cca560f05ed72b6b3aba47c3a7dd1f290/src/WebpackAssetManager.ts#L53-L54

return this.#inner.getPath(filename, data);

indeed the compilation object only has a hash property, therefore getPath will only replace [hash] and nothing else;
Webpack 5 does replace [name] though.

Interestingly I also use the built in CssExtractRspackPlugin

plugins: [
    ...
    new rspack.CssExtractRspackPlugin({
      filename: './style/[name].min.css',
    }),
  ],

which does replace [name] though; I wonder what's the difference?

Meantime perhaps we should add a note in https://rspack.dev/guide/compatibility/plugin#plugin-compatibility?

Reproduce link

No response

Reproduce Steps

Just add

import { LicenseWebpackPlugin } from 'license-webpack-plugin;

...
plugins: [
    ...
    new LicenseWebpackPlugin(),
],
...

to any rspack config. The output license file would be [name].license.txt[sic].

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions