Installation
Usage
React Scan provides a component name plugin that works with Webpack via the unplugin interface.webpack.config.js
Plugin Options
Files to include for transformation.Default:
**/*.{mtsx,mjsx,tsx,jsx}Files to exclude from transformation.Default excludes:
**/node_modules/****/_app.{jsx,tsx,js,ts}(Next.js)**/_document.{jsx,tsx,js,ts}(Next.js)**/api/**/*(Next.js API routes)**/.million/**/*(Million.js)
Plugin enforcement order.
Additional flags for component name transformation.
What It Does
The component name plugin automatically adds display names to your React components, making them easier to identify in React Scan. Before:Full Configuration Example
webpack.config.js
Integrating React Scan
After setting up the Webpack plugin, initialize React Scan in your application:src/index.js
Create React App
For Create React App projects, you’ll need to use a tool like CRACO or react-app-rewired to customize the Webpack configuration.Using CRACO
craco.config.js
package.json:
Next.js
For Next.js projects, modifynext.config.js:
next.config.js
pages/_app.tsx
TypeScript
The plugin works seamlessly with TypeScript. Ensure yourtsconfig.json includes JSX files:
tsconfig.json
Troubleshooting
Plugin not working
-
Verify the plugin is in the
pluginsarray: -
Check that file extensions match the
includepattern - Ensure the plugin loads after your JSX/TSX loader