create-react-app-fullstack
Advanced tools
Comparing version 1.1.11 to 1.1.12
@@ -82,2 +82,3 @@ #!/usr/local/bin/node | ||
pkgJson.scripts.fullstart = samplePackage.scripts.fullstart; | ||
pkgJson.scripts.backstart = samplePackage.scripts.backstart; | ||
pkgJson.scripts.build = samplePackage.scripts.build; | ||
@@ -98,4 +99,6 @@ | ||
console.log(); | ||
console.log(chalk.white("To update with back-end changes, run ") + chalk.cyan("npm run fullstart") + chalk.white(" to make automatic updates to front-end and back-end edits. This method disables hot-reloading, so you'll want to refresh the browser to see updates.")) | ||
console.log(chalk.white("To update with back-end and front-end changes, run ") + chalk.cyan("npm run fullstart") + chalk.white(" to make automatic updates to front-end and back-end edits. This method disables hot-reloading, so you'll want to refresh the browser to see updates.")) | ||
console.log(); | ||
console.log(chalk.white("To update with back-end only, run ") + chalk.cyan("npm run backstart") + chalk.white("This is a basic nodemon script for reloading the server without rebuilding the front end on each update.")) | ||
console.log(); | ||
console.log(chalk.white("To build a deployment ready version, run ") + chalk.cyan("npm run build") + chalk.white(" just as you would in create-react-app. You can preview the build result using ") + chalk.cyan("nodemon server.")) | ||
@@ -102,0 +105,0 @@ console.log(); |
@@ -26,2 +26,3 @@ var samplePackage = { | ||
"fullstart": "node scripts/starter.js --fullstack", | ||
"backstart": "node scripts/starter.js --backend", | ||
"build": "node scripts/build-fullstack.js", | ||
@@ -28,0 +29,0 @@ "test": "react-scripts test --env=jsdom", |
{ | ||
"name": "create-react-app-fullstack", | ||
"version": "1.1.11", | ||
"version": "1.1.12", | ||
"description": "Turn create-react-app into a fullstack app by adding Express and Sequelize", | ||
@@ -23,3 +23,4 @@ "main": "index.js", | ||
"server", | ||
"database" | ||
"database", | ||
"react" | ||
], | ||
@@ -26,0 +27,0 @@ "author": "ekatzenstein", |
@@ -8,2 +8,9 @@ # create-react-app-fullstack | ||
## Versions | ||
1.2.0 - Added 'backstart' functionality <br/> | ||
1.1.0 - Eject Prompts <br/> | ||
1.0.0 - Initial release <br/> | ||
<br/> | ||
## Installation | ||
@@ -59,3 +66,3 @@ <br/> | ||
After the database is seeded, you should be all set. To enable front-end development with hot-reloading, use the same script as create-react-app: | ||
After the database is seeded, you should be all set. To enable front-end development with hot-reloading, use the same script as create-react-app. This does not listen to updates on the back-end: | ||
@@ -71,3 +78,3 @@ ``` | ||
To automate updates from back-end development, you can run the script below. The difference between this script and the one above: hot-reloading is disabled. Requires navigating to the localhost and refreshing the page: | ||
To automate updates from back-end and front-end development, you can run the script below. The difference between this script and the one above: hot-reloading is disabled. Requires navigating to the localhost and refreshing the page: | ||
@@ -78,3 +85,13 @@ ``` | ||
<br/> | ||
### backstart | ||
As the project gets larger, the 'fullstack' command can take time to rebuild the back-end **and** front-end. This command listens for back-end updates only. In the first step, front-end components are built as static files (this happens only once). After this step, the script listens to server updates with **nodemon**. Use this for back-end updates when 'fullstart' takes too long to rebuild. | ||
``` | ||
npm run backstart | ||
``` | ||
<br/> | ||
@@ -81,0 +98,0 @@ |
@@ -8,3 +8,3 @@ const debug = require('debug')('sql') | ||
const url = process.env.DATABASE_URL || `postgres://localhost:5432/`; | ||
const url = process.env.DATABASE_URL || `postgres://localhost:5432/${name}`; | ||
@@ -14,3 +14,3 @@ console.log(chalk.yellow(`Opening database connection to ${url}${name}`)); | ||
// create the database instance | ||
const db = module.exports = new Sequelize(url+name, { | ||
const db = module.exports = new Sequelize(url, { | ||
logging: debug, // export DEBUG=sql in the environment to get SQL queries | ||
@@ -17,0 +17,0 @@ define: { |
var exec = require('child_process').execSync; | ||
var yargs = require('yargs'); | ||
var chalk = require('chalk'); | ||
@@ -7,4 +8,12 @@ if(yargs.argv.fullstack){ | ||
} | ||
else if(yargs.argv.backend){ | ||
console.log(chalk.cyan("Initiating back-end development environment. The first step is to rebuild front-end src components as static files. This will only happen once. To skip this step and use existing static builds, run 'nodemon server' instead.")) | ||
console.log(); | ||
console.log("Creating an optimized production build...") | ||
exec("node scripts/build-fullstack"); | ||
console.log(chalk.cyan("Static files built! Initiating server...")) | ||
exec("nodemon server",{stdio:[0,1,2]}) | ||
} | ||
else{ | ||
exec("node scripts/start-fullstack",{stdio:[0,1,2]}); | ||
} |
@@ -13,3 +13,3 @@ // src/components/About/index.js | ||
<h1> | ||
About | ||
React Router working! | ||
</h1> | ||
@@ -16,0 +16,0 @@ </div> |
import React, { Component } from 'react'; | ||
import classnames from 'classnames'; | ||
import {Link} from 'react-router'; | ||
import logo from './logo.svg'; | ||
@@ -19,2 +19,5 @@ import './style.css'; | ||
</p> | ||
<Link to='about'>Test React Router</Link> | ||
<br/> | ||
<br/> | ||
<a href='./api/express-test'>Test if Express is working</a> | ||
@@ -21,0 +24,0 @@ <br/> |
// src/index.js | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { browserHistory } from 'react-router'; | ||
import { hashHistory } from 'react-router'; | ||
@@ -11,4 +11,4 @@ import Routes from './routes'; | ||
ReactDOM.render( | ||
<Routes history={browserHistory} />, | ||
<Routes history={hashHistory} />, | ||
document.getElementById('root') | ||
); |
75658
955
130