Skip to content

Commit

Permalink
fix: adapt to types of terser plugin (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
licg9999 committed May 17, 2023
1 parent 07b68a5 commit 04b8129
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TerserWebpackPluginController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export class TerserWebpackPluginController {
setNamesToBeMinimized(names: Iterable<string>): void {
if (!this.terserWebpackPlugin) return;

const newTest: TerserWebpackPlugin.Rules = this.iniTest ? flatten([this.iniTest]) : [];
const newTest: (string | RegExp)[] = this.iniTest ? flatten([this.iniTest]) : [];
for (const name of names) {
newTest.push(
// Aligns to:
// https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/ModuleFilenameHelpers.js#L73
new RegExp(`^${name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}$`, 'i')
);
}
this.terserWebpackPlugin.options.test = newTest;
this.terserWebpackPlugin.options.test = newTest as TerserWebpackPlugin.Rules;
}
}

0 comments on commit 04b8129

Please sign in to comment.