All Projects → reearth → craco-cesium

reearth / craco-cesium

Licence: MIT license
Let's use 🌍Cesium with create-react-app today!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to craco-cesium

vue-cesium-demo
Demos of vue-cesium component
Stars: ✭ 87 (+50%)
Mutual labels:  cesium
craco-linaria
A craco plugin to use Linaria zero-runtime CSS in JS library in a create react app.
Stars: ✭ 29 (-50%)
Mutual labels:  create-react-app
spring-boot-create-react-app
Simple template to create a spring boot back-end with create react app front-end combined into a microservice
Stars: ✭ 25 (-56.9%)
Mutual labels:  create-react-app
react-antd-admin
react-antd-admin 是一个后台集成解决方案,它基于 react 和 antd; 内置了动态路由,标签页缓存,权限验证、切换功能
Stars: ✭ 42 (-27.59%)
Mutual labels:  create-react-app
react-production-deployment
Deploy your React app to production on Netlify, Vercel and Heroku
Stars: ✭ 51 (-12.07%)
Mutual labels:  create-react-app
DM Tools
An open-source Dungeons and Dragons DM helper desktop app built with React.js, Redux, SCSS
Stars: ✭ 41 (-29.31%)
Mutual labels:  create-react-app
tutorial-react-docker
Boilerplate React app in Docker container with ENV args
Stars: ✭ 63 (+8.62%)
Mutual labels:  create-react-app
arnold
🎬 A modern Kodi web interface
Stars: ✭ 16 (-72.41%)
Mutual labels:  create-react-app
modular
Scaffold a react monorepo and its component parts.
Stars: ✭ 13 (-77.59%)
Mutual labels:  create-react-app
docker-files
Teracy docker-files project to build common Docker images
Stars: ✭ 87 (+50%)
Mutual labels:  create-react-app
worthit
💸 Vale a pena? Calcule o preço anual de um item com essa PWA
Stars: ✭ 18 (-68.97%)
Mutual labels:  create-react-app
eslint-plugin-react-app
ESLint configuration used by Create React App
Stars: ✭ 52 (-10.34%)
Mutual labels:  create-react-app
webcam-object-detection
Tensorflow.js webcam object detection in React
Stars: ✭ 24 (-58.62%)
Mutual labels:  create-react-app
character-overlay
Web App for adding an OBS overlay with character information such as name, picture, and health for your favorite role-playing game.
Stars: ✭ 17 (-70.69%)
Mutual labels:  create-react-app
hotlist
今日热榜(前端)
Stars: ✭ 51 (-12.07%)
Mutual labels:  create-react-app
react-mobx-router
Create React App with React Router 4 and MobX + Internationalization
Stars: ✭ 90 (+55.17%)
Mutual labels:  create-react-app
cruise
A Continuous Integration (CI) management system homework from Thought Works
Stars: ✭ 13 (-77.59%)
Mutual labels:  create-react-app
cesium-materials-pack
A Cesium plugin with procedurally-shaded materials such as bricks, wood, and noise patterns
Stars: ✭ 71 (+22.41%)
Mutual labels:  cesium
CesiumJs3DTileServer
cesiumgis.com/
Stars: ✭ 25 (-56.9%)
Mutual labels:  cesium
universal-scripts
Build universal apps without configuration.
Stars: ✭ 23 (-60.34%)
Mutual labels:  create-react-app

craco-cesium

Let's use 🌍Cesium with create-react-app today!

This is a plugin for @craco/craco.

💡Tip: Resium is also recommended.

Very very easy usage

1. Create a React project

npm install -g create-react-app
# or
yarn global add create-react-app

create-react-app example
cd example

2. Install modules

In your create-react-app project, install modules:

npm install --save @craco/craco craco-cesium cesium resium
# or
yarn add @craco/craco craco-cesium cesium resium

3. Rewrite npm scripts

Rewrite npm scripts in package.json as following:

{
  // ...
  "scripts": {
    "start": "craco start", // react-scripts -> craco
    "build": "craco build", // react-scripts -> craco
    "test": "craco test",   // react-scripts -> craco
    "eject": "react-scripts eject"
  },
  // ...
}

4. Create craco config file

Create craco.config.js in the project root:

module.exports = {
  plugins: [
    {
      plugin: require("craco-cesium")()
    }
  ]
};

5. Congratulations! 🎉

Set up is complete! Enjoy your Cesium life.

You can import Cesium as following:

import { Viewer, Entity, Color } from "cesium";

If you are using Resium, you can import Cesium and Resium as following.

import { Color } from "cesium";
import { Viewer, Entity } from "resium";

🔥Pro Tip: Enabling HMR

  • 💡 Example project is here.
  1. yarn add craco-plugin-react-hot-reload react-hot-loader @hot-loader/react-dom

⚠️ @hot-loader/react-dom's version should be the same as react's.

  1. Add an alias of webpack and craco-plugin-react-hot-reload plugin to craco.config.js:
module.exports = {
  webpack: {
    alias: {
      "react-dom": "@hot-loader/react-dom"
    }
  },
  plugins: [
    { plugin: require("craco-plugin-react-hot-reload") },
    { plugin: require("craco-cesium")() }
  ]
};
  1. Wrap root component with hot function in src/App.js
export default App;

to

import { hot } from "react-hot-loader/root";

// ~~~~~~~~~~~~~~~~~~~~~~~~~

export default hot(App);

Done!

Please refer to react-hot-loader to refer to the details.

Options

If the option is omiited, the default options is used:

CracoCesiumPlugin({
  loadPartially: false,
  loadCSSinHTML: true,
  cesiumPath: "cesium"
});

loadPartially

If false, whole Cesium will be loaded in HTML and window.Cesium is used in import { ... } from "cesium";. This is the easiest way.

Otherwise, Cesium will be load partially and bundled in the JS. You have to install strip-pragma-loader to build Cesium for production: npm i -S strip-pragma-loader.

For more details, refer to Cesium official tutorial.

loadCSSinHTML

If true, Widgets/widgets.css in Cesium is loaded in HTML.

Otherwise, you have to load the CSS once manually as following.

If loadPartially is true:

import "cesium/Widgets/widgets.css";

Otherwise:

import "cesium/Build/CesiumUnminified/Widgets/widgets.css";

cesiumPath

Directory path destination to copy Cesium files.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].