Skip to content

Commit

Permalink
Add extensions to config file patterns in webpack plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 4, 2023
1 parent 18ff2b9 commit 1f857a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/knip/src/plugins/webpack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ENABLERS = ['webpack'];

export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);

export const CONFIG_FILE_PATTERNS = ['webpack.config*.{js,ts}'];
export const CONFIG_FILE_PATTERNS = ['webpack.config*.{js,ts,mjs,cjs,mts,cts}'];

const hasBabelOptions = (use: RuleSetUseItem) =>
Boolean(use) &&
Expand Down Expand Up @@ -102,7 +102,7 @@ const findWebpackDependencies: GenericPluginCallback = async (configFilePath, op
if (isProduction) return [...entryPatterns];

const scripts = Object.values(manifest.scripts ?? {});
const webpackCLI = scripts.some(script => script?.includes('webpack ')) ? ['webpack-cli'] : [];
const webpackCLI = scripts.some(script => script && /(?<=^|\s)webpack(?=\s|$)/.test(script)) ? ['webpack-cli'] : [];
const webpackDevServer = scripts.some(script => script?.includes('webpack serve')) ? ['webpack-dev-server'] : [];

return compact([...entryPatterns, ...dependencies, ...webpackCLI, ...webpackDevServer]);
Expand Down

0 comments on commit 1f857a4

Please sign in to comment.