'Exclude fontawesome ttf files from webpack output

I am using webpack and fontawesome, which has files fa-regular-400.ttf, fa-solid-900.ttf, etc.

I want to exclude ttf files, so I did this:

test: /\.(woff2|ttf)$/i,
exclude: [ /fa-.*\.ttf$/ ],
type: 'asset/resource',
// ...other config

That excludes the ttf files from my /fonts directory, but they are nonetheless placed in the output root / as hash1.ttf, hash2.ttf, etc.

I want to exclude them completely: I don't want them in the output. Is that possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source