├── .gitignore ├── LICENSE ├── README.md ├── index.html ├── package.json └── src ├── App.css ├── App.js ├── App.test.js ├── favicon.ico ├── index.css ├── index.js ├── logo.svg └── pages.js /.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 | npm-debug.log 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Glen Maddern 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Create React App Snapshot 2 | 3 | A combination of [Create React App](https://github.com/facebookincubator/create-react-app) and [React Snapshot](https://github.com/geelen/react-snapshot) 4 | 5 | Visit the live site here: [create-react-app-snapshot.surge.sh](https://create-react-app-snapshot.surge.sh) 6 | 7 | See what it takes to convert one to the other by looking at this [diff](https://github.com/geelen/create-react-app-snapshot/compare/303f774...master) 8 | 9 | ### Try it out 10 | 11 | ``` 12 | npm install 13 | npm run publish -- YOUR_DOMAIN_HERE.surge.sh 14 | ``` 15 | 16 | That's it! 17 | 18 | --- 19 | 20 | Made with ♥️ and while too jetlagged to work on [frontend.center](https://frontend.center) by Glen Maddern 21 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | React App 8 | 9 | 10 |
11 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "snapshotting", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "pushstate-server": "^1.14.0", 7 | "react-router": "^2.7.0", 8 | "react-snapshot": "^1.0.2", 9 | "surge": "^0.18.0", 10 | "react-scripts": "0.4.1" 11 | }, 12 | "dependencies": { 13 | "react": "^15.3.1", 14 | "react-dom": "^15.3.1" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build && react-snapshot", 19 | "publish": "npm run build && surge build", 20 | "test": "react-scripts test --env=jsdom", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": "./node_modules/react-scripts/config/eslint.js" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | class App extends Component { 6 | render() { 7 | return ( 8 |
9 |
10 | logo 11 |

Welcome to React

12 |
13 | { this.props.children } 14 |
15 | ); 16 | } 17 | } 18 | 19 | export default App; 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geelen/create-react-app-snapshot/ec9486c8a14af51d60b9c027b1bad68eb7bd425e/src/favicon.ico -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: sans-serif; 5 | } 6 | 7 | nav { 8 | display: flex; 9 | justify-content: center; 10 | } 11 | 12 | nav > * + * { 13 | margin-left: 1rem; 14 | } 15 | 16 | section { 17 | width: 40rem; 18 | max-width: calc(100vw - 2rem); 19 | margin: 0 auto; 20 | } 21 | 22 | section > * + * { 23 | margin-top: 1rem; 24 | } 25 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {render} from 'react-snapshot' 3 | import App from './App'; 4 | import './index.css'; 5 | import {Router, Route, browserHistory, IndexRoute} from 'react-router' 6 | import {Index, Login, About, Admin, FourOhFour} from './pages' 7 | 8 | render( 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | , 18 | document.getElementById('root') 19 | ); 20 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/pages.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router' 3 | 4 | export const Index = () => ( 5 |
6 |

This is the index page!

7 |

If you have JS enabled, the links below should work instantaneously. If not, or if you JS is taking a long time to load, your site still works and is valid. Yay!

8 | 12 |
13 | ) 14 | 15 | export const Admin = () => ( 16 |
17 |

You're logged in!

18 |

This page isn't snapshotted. If you refresh this page with javascript off you won't see anything.

19 | 22 |
23 | ) 24 | 25 | export const Login = () => ( 26 |
27 |

This is the login form

28 |
29 |

This button isn't clicked during the snapshot process. Only links are crawled.

30 | 31 |
32 | 36 |
37 | ) 38 | 39 | export const About = () => ( 40 |
41 |

About this site

42 |

This should all be snapshotted.

43 | 48 |
49 | ) 50 | 51 | export const FourOhFour = () => ( 52 |
53 |

Four Oh Four Yo.

54 |
55 | ) 56 | --------------------------------------------------------------------------------