Customize create react app



usecreate-react-appIf you want to change some configurations, one way is to useejectDirective, but subsequent updates may not be synchronized. Another way is to usereact-app-rewiredOverwrite the corresponding configuration. This method cannot be set. A better way is to make user-defined modifications directly based on the original build script, which is convenient to synchronize subsequent updates.

brief introduction

create-react-appIt contains many different libraries and usesLernaManage. The relevant scripts built are mainly inreact-scriptsYes. adoptForkYou can publish your own version or synchronize the official version.


1 Fork

Log in to GitHub’s account, forkcreate-react-app。 For more details, seeFork a repo

Customize create react app

2. Modify the corresponding library

After fork, clone the corresponding library locally. Before modifying, it is recommended to create your own modification branch based on the published branch. As an example, in/packages/react-scripts/scripts/init.jsAdd some print logs to the.

Customize create react app

3 release package

Because it’s fork’s bag, insidepackage.jsonSome of the description information needs to be modified. At least insidenameThe field value needs to be changed. The name of the example is changed tocustomize-react-scripts。 For other description information, judge whether it needs to be modified according to the actual situation.

npm login
npm publish

For detailed description of release package, seehere

4 using custom packages

After publishing successfully, go to a directory and execute the following command:

npx create-react-app test-app --scripts-version customize-react-scripts

You can see the following information prompt.

Customize create react app

After the installation is successful, you can see the previously added prompt information.

Customize create react app

reference material

Recommended Today

SQL exercise 20 – Modeling & Reporting

This blog is used to review and sort out the common topic modeling architecture, analysis oriented architecture and integration topic reports in data warehouse. I have uploaded these reports to GitHub. If you are interested, you can have a lookAddress: recorded a relatively complete development process in my hexo blog deployed on GitHub. You can […]