find-webpack is a utility library designed to programmatically locate and modify Webpack configuration settings, particularly useful for projects built with `react-scripts` (Create React App) or custom Webpack setups. As of its latest stable version, 2.2.1 (released January 2021), it provides functions to extract Webpack options, including handling the nuances of `react-scripts`'s hidden configurations. It also offers specific utilities for integrating with tools like Cypress, enabling cleanup of optimization plugins and dynamic addition of folders to Babel's transpilation scope for testing purposes. While its release cadence has been irregular since 2021, it was actively maintained with features and bug fixes throughout 2020, differentiating itself by simplifying complex Webpack config access and modification for specific ecosystem integrations.
npm install find-webpackVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to find an application's Webpack configuration (especially from react-scripts) and then modify it using `cleanForCypress` to prepare it for Cypress component testing, including adding coverage instrumentation and specifying additional folders for Babel transpilation.
Ensure `process.env.NODE_ENV` is set to 'test' before calling `getWebpackOptions` or `tryLoadingWebpackConfig` if you encounter issues with environment-dependent config loading in `react-scripts`.
Run your script from the root of your project where `package.json` is located, or ensure your `process.cwd()` is correctly set if running from a non-standard environment.
Be aware of these side effects. If precise control over `NODE_ENV` and `BABEL_ENV` is critical, consider resetting them after `find-webpack` operations or inspecting their values. For `v2.0.0+` specifically, `NODE_ENV` being 'test' is expected for some scenarios.
Upgrade to `find-webpack@2.2.1` or newer to resolve this bug. If unable to upgrade, ensure `options.babelPresets` is explicitly defined if you're dynamically modifying Babel configuration.
Upgrade `find-webpack` to version `2.2.1` or later. Alternatively, ensure the Babel configuration passed to `cleanForCypress` explicitly defines presets if you're manipulating them.
Ensure that the script calling `getWebpackOptions()` is executed from the root directory of your project, where the `package.json` file resides.
Be mindful of this side effect. If you need specific environment variables, set them before calling `find-webpack` functions or reset them immediately afterwards.
No dependency data recorded yet.