{"id":20251727,"url":"https://github.com/osdevisnot/react-app-rewire-create-react-library","last_synced_at":"2025-04-10T23:15:55.100Z","repository":{"id":72443155,"uuid":"96662344","full_name":"osdevisnot/react-app-rewire-create-react-library","owner":"osdevisnot","description":"Use create-react-app to build react libraries","archived":false,"fork":false,"pushed_at":"2017-07-09T08:19:00.000Z","size":6,"stargazers_count":10,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T20:37:13.120Z","etag":null,"topics":[],"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/osdevisnot.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-09T05:04:49.000Z","updated_at":"2023-04-03T13:39:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"71b3966c-f121-4c2c-bc8e-b29ec399030e","html_url":"https://github.com/osdevisnot/react-app-rewire-create-react-library","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"b3a123efd5fad216906182f0e6ef8cbbfff5d5f4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdevisnot%2Freact-app-rewire-create-react-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdevisnot%2Freact-app-rewire-create-react-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdevisnot%2Freact-app-rewire-create-react-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdevisnot%2Freact-app-rewire-create-react-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osdevisnot","download_url":"https://codeload.github.com/osdevisnot/react-app-rewire-create-react-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247861679,"owners_count":21008545,"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":[],"created_at":"2024-11-14T10:12:31.322Z","updated_at":"2025-04-10T23:15:55.072Z","avatar_url":"https://github.com/osdevisnot.png","language":"JavaScript","readme":"# react-app-rewire-create-react-library\nUse create-react-app to build react libraries.\n\nThis gives you ability to reuse most of CRA setup for building your libraries.\n\n## Installation\n```\nyarn add --dev react-app-rewire-create-react-library\n\n# or use npm if you don't have yarn yet\n\nnpm install --save-dev react-app-rewire-create-react-library\n```\n\n## Usage\nIn the `config-overrides.js` you created for [react-app-rewired](https://github.com/timarney/react-app-rewired) add this code:\n\n```\nconst rewireCreateReactLibrary = require('react-app-rewire-create-react-library');\n\nmodule.exports = function override(config, env) {\n  config = rewireCreateReactLibrary(config, env);\n  return config;\n};\n```\n\nIn `package.json`, add a separate npm script to build library\n\n```\n{\n  \"scripts\": {\n    ...\n    \"build-library\": \"react-app-rewired build --library\",\n    ...\n  }\n}\n```\n\nAnd you can now use CRA to build your library 💪\n\n## Conventions\n\nThe library name will be read from `name` property in your `package.json`. For scoped NPM packages, the scope name will be omited from library name.\n\nThe webpack entry file is read from `module` property in `package.json` and output file \u0026 path are read from `main` property in `package.json`. Why? [read here](https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md#typical-usage)\n\nAll the dependencies in your `package.json` will ba added to as commonjs externals to webpack config.\n\nThis package will be activated only when a `--library` flag is detected in npm script. This eliminated the need to maintain separate `config-overrides.js` for app and library builds.\n\n## Caveats\n\nSetting `main` file to be outside of `build` folder would cause CRA to throw error when reporting file sizes. To avoid this, always set `\"main\"` to be inside `build` folder. For example:\n```\n# GOOD: uses build directory for output\n\"main\": \"build/my-library.js\",\n\n# BAD: uses dist directory for output\n\"main\": \"dist/my-library.js\",\n```\n\n`public` folder always gets copied over to build even for library builds. This is currently handled and defaulted inside CRA, there is no way to override this at the moment. However, you can use `.npmignore` to avoid publishing these files to NPM:\n```\n# .npmignore\n\n**\n!build/*.js\n!build/*.map\n```\n\n## License\nLicensed under the MIT License, Copyright @ 2017 osdevisnot. See LICENSE.md for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosdevisnot%2Freact-app-rewire-create-react-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosdevisnot%2Freact-app-rewire-create-react-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosdevisnot%2Freact-app-rewire-create-react-library/lists"}