{"id":15551436,"url":"https://github.com/bahmutov/find-webpack","last_synced_at":"2025-09-28T22:30:32.843Z","repository":{"id":49058495,"uuid":"253374911","full_name":"bahmutov/find-webpack","owner":"bahmutov","description":"Utility to find webpack settings in react-scripts and other situations","archived":false,"fork":false,"pushed_at":"2022-08-20T20:54:27.000Z","size":410,"stargazers_count":6,"open_issues_count":10,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T20:52:08.203Z","etag":null,"topics":["utility","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-06T02:17:34.000Z","updated_at":"2023-09-08T18:05:31.000Z","dependencies_parsed_at":"2022-09-26T20:22:14.785Z","dependency_job_id":null,"html_url":"https://github.com/bahmutov/find-webpack","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Ffind-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Ffind-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Ffind-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Ffind-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/find-webpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234565111,"owners_count":18853251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["utility","webpack"],"created_at":"2024-10-02T14:04:59.393Z","updated_at":"2025-09-28T22:30:27.570Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# find-webpack [![semantic-release][semantic-image] ][semantic-url] [![Build status][ci-image] ][ci-url]\n\n\u003e Utility to find webpack settings in react-scripts and other situations\n\n## Use\n\n```shell\nnpm i -S find-webpack\n```\n\n```js\nconst fw = require('find-webpack')\nconst config = fw.getWebpackOptions()\n// if config is an object, we found it!\n```\n\nWorks with `react-scripts` and ejected `react-scripts`. Uses `development` environment.\n\n**Note:** `react-scripts` assumes there is `package.json` file in the current working directory, otherwise it won't load.\n\n### tryLoadingWebpackConfig\n\nLoading Webpack config from `webpack.config.js` might need `NODE_ENV` set, and other tricks.\n\n```js\nconst fw = require('find-webpack')\nconst config = fw.tryLoadingWebpackConfig('path/to/webpack.config.js')\n```\n\nReturns `undefined` if cannot load the config object.\n\n**Note:** when loading the config object, this module sets `process.env.BABEL_ENV` and `process.env.NODE_ENV` to `development` and keeps it.\n\n### Cypress\n\nThere is a utility method for cleaning up the found Webpack config for using with Cypress webpack preprocessor: removing optimization plugins, etc.\n\n```js\nconst fw = require('find-webpack')\nconst config = fw.getWebpackOptions()\nif (config) {\n  // config is modified in place\n  const opts = {\n    reactScripts: true, // cleaning for react-scripts?\n    coverage: true, // adds babel-plugin-istanbul\n  }\n  fw.cleanForCypress(opts, config)\n}\n```\n\nIf you are using `opts.reactScripts = true`, you can also add the component test folder to be transpiled using the same options as `src` folder.\n\n```js\nconst componentTestFolder = ... // from Cypress config\n// config is modified in place\nconst opts = {\n  reactScripts: true, // cleaning for react-scripts?\n  addFolderToTranspile: componentTestFolder,\n  coverage: true // adds babel-plugin-istanbul\n}\nfw.cleanForCypress(opts, config)\n```\n\nand you can add option `looseModules: true` to insert Babel plugin [@babel/plugin-transform-modules-commonjs](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs) to allow mocking named imports.\n\n### addFolderToTranspile\n\nThis setting could be an individual folder or a list of folders. For example, you might want to transpile component test folder and fixture folder to allow requiring fixture files from tests.\n\n```js\nconst componentTestFolder = ... // from Cypress config\nconst fixtureFolder = ... // from Cypress config\n// config is modified in place\nconst opts = {\n  reactScripts: true, // cleaning for react-scripts?\n  addFolderToTranspile: [componentTestFolder, fixtureFolder],\n  coverage: true // adds babel-plugin-istanbul\n}\nfw.cleanForCypress(opts, config)\n```\n\n## Debugging\n\nRun with environment variable `DEBUG=find-webpack` to see verbose logs\n\n## About\n\n### Author\n\nGleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2017\n\n- [@bahmutov](https://twitter.com/bahmutov)\n- [glebbahmutov.com](https://glebbahmutov.com)\n- [blog](https://glebbahmutov.com/blog)\n\n### License\n\n[MIT](LICENSE) - do anything with the code, but don't blame me if it does not work.\n\n[ci-image]: https://github.com/bahmutov/find-webpack/workflows/ci/badge.svg?branch=master\n[ci-url]: https://github.com/bahmutov/find-webpack/actions\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Ffind-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Ffind-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Ffind-webpack/lists"}