Skip to content

Instantly share code, notes, and snippets.

@benrudolph
Last active February 24, 2018 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benrudolph/1835dd0da60b2c286704d157865a404d to your computer and use it in GitHub Desktop.
Save benrudolph/1835dd0da60b2c286704d157865a404d to your computer and use it in GitHub Desktop.
Starting new React projects

Start a new typescript react project

create-react-app <app_name> --scripts-version=react-scripts-ts

Basic deps

# For building css and js in the same command
yarn add npm-run-all

# For using Sass
yarn add node-sass-chokidar

# React Deps
yarn add react react-redux redux react-redux-router history react-router-dom

# Useful utils
yarn add bootstrap jquery

Ensuring that you can use absolute paths when importing

# tsconfig.json
"compilerOptions": {
  ...
  "baseUrl": "src/"
}

Package.json scripts for building sass and js

# package.json
{
  ...
  "scripts": {
    "watch-css": "npm run build-css && node-sass-chokidar  --include-path ./src --include-path ./node_modules  src/ -o src/ --watch --recursive",
    "start-js": "node scripts/start.js",
    "start": "npm-run-all -p watch-css start-js",
    "build-js": "node scripts/build.js",
    "build-css": "node-sass-chokidar  --include-path ./src --include-path ./node_modules  src/ -o src/",
    "build": "npm-run-all build-css build-js",
    "test": "node scripts/test.js --env=jsdom"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment