web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

  1. # babel-preset-react-app
  2. This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
  3. Please refer to its documentation:
  4. - [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
  5. - [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
  6. ## Usage in Create React App Projects
  7. The easiest way to use this configuration is with [Create React App](https://github.com/facebook/create-react-app), which includes it by default. **You don’t need to install it separately in Create React App projects.**
  8. ## Usage Outside of Create React App
  9. If you want to use this Babel preset in a project not built with Create React App, you can install it with the following steps.
  10. First, [install Babel](https://babeljs.io/docs/setup/).
  11. Then install babel-preset-react-app.
  12. ```sh
  13. npm install babel-preset-react-app --save-dev
  14. ```
  15. Then create a file named `.babelrc` with following contents in the root folder of your project:
  16. ```json
  17. {
  18. "presets": ["react-app"]
  19. }
  20. ```
  21. This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled.
  22. ## Usage with Flow
  23. Make sure you have a `.flowconfig` file at the root directory. You can also use the `flow` option on `.babelrc`:
  24. ```json
  25. {
  26. "presets": [["react-app", { "flow": true, "typescript": false }]]
  27. }
  28. ```
  29. ## Usage with TypeScript
  30. Make sure you have a `tsconfig.json` file at the root directory. You can also use the `typescript` option on `.babelrc`:
  31. ```json
  32. {
  33. "presets": [["react-app", { "flow": false, "typescript": true }]]
  34. }
  35. ```
  36. ## Absolute Runtime Paths
  37. Absolute paths are enabled by default for imports. To use relative paths instead, set the `absoluteRuntime` option in `.babelrc` to `false`:
  38. ```
  39. {
  40. "presets": [["react-app", { "absoluteRuntime": false }]]
  41. }
  42. ```