React Project Construction

Source: Internet
Author: User

1. Download and installNode. jsThe node. js environment is required.

2. After selection, selectCreat-react-appRun the command to install $ NPM install-G create-react-app.

3. Create a project and enter the command (My-appIs the name, take it by yourself) $ create-react-app my-app

4. Enter the project and enter the command $ CD my-app

5. Run the project and enter the command $ NPM start.

6. SelectReact-router-domRun the command to install $ NPM install -- save react-router-dom.

7. Compare fetch and AXIOS SelectionFetchAnd then enter the command to install $ NPM install whatwg-Fetch -- save

8. Because I am developing a micro-mall project, UI component integration SelectionAnt-design-mobileAnd then enter the command to install $ NPM install antd-mobile -- save

9. IntroductionReact-app-rewiredAnd modify the startup configuration in package. JSON $ NPM install react-app-rewired -- save-Dev

10. Create a config-overrides.js in the project root directory to modify the default configuration, enter the code

module.exports = function override (config, env) {
   // do stuff with the webpack config ...
   return config;
};
11. Install the babel plugin that loads component code and styles on demand and modify the config-overrides.js file $ npm install babel-plugin-import --save-dev

const {injectBabelPlugin} = require (‘react-app-rewired’);
module.exports = function override (config, env) {
   config = injectBabelPlugin ([‘import‘, {libraryName: ‘antd-mobile’, style: ‘css’}], config);
   return config;
};
  12. Write css in component mode $ npm install --save styled-components

React project construction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.