├── public ├── favicon.ico └── index.html ├── src ├── index.css ├── index.js ├── App.test.js ├── About.js ├── App.css ├── App.js └── logo.svg ├── .travis.yml ├── package.json ├── .gitignore ├── LICENSE └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xkawi/create-react-app-now/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | import './index.css'; 5 | 6 | ReactDOM.render( 7 | , 8 | document.getElementById('root') 9 | ); 10 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | }); 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "4" 5 | - "5" 6 | - "6" 7 | - "stable" 8 | 9 | sudo: false 10 | 11 | before_script: 12 | - export DISPLAY=:99.0 13 | - sh -e /etc/init.d/xvfb start 14 | 15 | script: 16 | - npm install 17 | - npm test -------------------------------------------------------------------------------- /src/About.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | 4 | class About extends Component { 5 | render() { 6 | return ( 7 |
About page here back | or Test Not Found Page
8 | ); 9 | } 10 | } 11 | 12 | export default About; 13 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 80px; 8 | } 9 | 10 | .App-header { 11 | background-color: #222; 12 | height: 150px; 13 | padding: 20px; 14 | color: white; 15 | } 16 | 17 | .App-intro { 18 | font-size: large; 19 | } 20 | 21 | @keyframes App-logo-spin { 22 | from { transform: rotate(0deg); } 23 | to { transform: rotate(360deg); } 24 | } 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-react-app-now", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "react-scripts": "0.9.5", 7 | "serve": "^6.0.6" 8 | }, 9 | "dependencies": { 10 | "react": "^15.4.0", 11 | "react-dom": "^15.4.0", 12 | "react-router": "^4.0.0", 13 | "react-router-dom": "^4.0.0" 14 | }, 15 | "scripts": { 16 | "now-start": "cd build && serve -s ./", 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test --env=jsdom", 20 | "eject": "react-scripts eject", 21 | "deploy": "now -e REACT_APP_SECRET_CODE=secretcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | 16 | # Logs 17 | logs 18 | *.log 19 | npm-debug.log* 20 | 21 | # Runtime data 22 | pids 23 | *.pid 24 | *.seed 25 | 26 | # Directory for instrumented libs generated by jscoverage/JSCover 27 | lib-cov 28 | 29 | # Coverage directory used by tools like istanbul 30 | coverage 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (http://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | jspm_packages 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional REPL history 51 | .node_repl_history -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Kawi Xiao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 16 | React App 17 | 18 | 19 |
20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | BrowserRouter as Router, 4 | Route, 5 | Link, 6 | Switch, 7 | } from 'react-router-dom' 8 | import About from './About'; 9 | import logo from './logo.svg'; 10 | import './App.css'; 11 | 12 | const NoMatch = ({ location }) => ( 13 |
14 |

No Match for {location.pathname}

15 | go back 16 |
17 | ) 18 | 19 | class App extends Component { 20 | render() { 21 | const secretCode = process.env.REACT_APP_SECRET_CODE; 22 | return ( 23 |
24 |
25 | logo 26 |

Welcome to React

27 |
28 |

29 | To get started, edit src/App.js and save to reload. 30 |

31 |

REACT_APP_SECRET_CODE: { !secretCode ? 'env not set yet' : secretCode }

32 |

about us

33 |
34 | ); 35 | } 36 | } 37 | 38 | const BasicApp = () => ( 39 | 40 |
41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 | ) 49 | 50 | export default BasicApp; 51 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # create-react-app-now 2 | 3 | Deploy React.js Static Web Apps generated with [facebook/create-react-app](https://github.com/facebook/create-react-app) to Zeit's awesome [Now.sh](https://zeit.co/now/) service. 4 | 5 | I wrote an article about this project here: [Zero Configuration Deployment for React app with Zeit Now](https://medium.com/@kawixiao/zero-configuration-deployment-for-react-apps-with-zeits-now-4f002be98c#.eyvj3mjdb) 6 | 7 | # Important 8 | 9 | UPDATE: create-react-app now officially recommend using "serve" to deploy your create-react-app project. The documentation can be found here: https://create-react-app.dev/docs/deployment 10 | 11 | I personally and strongly recommend you to check out [Next.js](https://zeit.co/blog/next) by Zeit team. 12 | That will be my personal go to choice as well when creating new React project, and deploy to now seamlessly. 13 | 14 | Though create-react-app-now can serves as an example on how you can use create-react-app and zeit's now together. 15 | 16 | Having said that, it is likely that I will not actively maintain this repo anymore (e.g. update the dependencies). I will still accept PR though. 17 | 18 | # Why 19 | 20 | create-react-app-now is created using [facebook/create-react-app](https://github.com/facebook/create-react-app). 21 | Although it supports deployment to github pages and heroku, it does not feel intuitive just yet, as we need to run lots of commands. 22 | 23 | This project is specifically to solve just that, with just 1 command: `npm run deploy` 24 | 25 | This is achieved by using Zeit's awesome [Now.sh](https://zeit.co/now/) service. 26 | It is fast, easy, and intuitive way of deploying your React app. 27 | 28 | # How 29 | 30 | Simply follow this step from getting started to deployment: 31 | 32 | ``` 33 | $ npm install -g now 34 | $ git clone https://github.com/xkawi/create-react-app-now 35 | $ npm install 36 | $ npm run deploy 37 | ``` 38 | 39 | First command installs the `now` cli globally as npm package. Another (or suggested) approach is to install [Now Desktop](https://zeit.co/desktop) to ensure automatic updates of `now` cli. 40 | 41 | Subsequent commands simply clone this repo, install necessary npm packages and deploy it to Now. 42 | 43 | Whenever you want to deploy new changes, just run `npm run deploy` again to get new public link, for free! :smile: 44 | 45 | You will enjoy all the benefits that Now offers out-of-the-box: real-time and immutable deployments all within 1 command. 46 | 47 | ## Note 48 | 49 | You might see some red text appears or warnings in the log. You can safely ignore this, because your project will still be deployed successfully. 50 | 51 | # Alternatives Deployment 52 | 53 | If you prefer something else, please refer to create-react-app documentation [here](https://create-react-app.dev/docs/deployment#other-solutions). 54 | 55 | # More 56 | 57 | Read more about create-react-app [here](https://github.com/facebook/create-react-app) 58 | 59 | Read more about Zeit's Now.sh [here](https://zeit.co/now) 60 | --------------------------------------------------------------------------------