Skip to content

Instantly share code, notes, and snippets.

@HugoDF
Created October 6, 2016 12:33
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 HugoDF/9d669ecd49292bbe2d6c192b97f18bb1 to your computer and use it in GitHub Desktop.
Save HugoDF/9d669ecd49292bbe2d6c192b97f18bb1 to your computer and use it in GitHub Desktop.
Frontend React/Mocha/Babel/Browserify setup with npm scripts and browser-sync. Requires a `./src` folder containing a react.js and an app.scss as well as a `./index.html` file.
{
"name": "frontend-starter",
"version": "1.0.0",
"description": "React, browserify and babel. With npm scripts and browser-sync",
"main": "index.js",
"config": {
"ut": "{,!(node_modules)/**/}*.test.js"
},
"scripts": {
"start": "npm run dev",
"clean": "rm -rf ./build",
"dev": "npm run build:dev && (npm run server & npm run watch)",
"server": "NODE_PATH=. browser-sync start -s 'build' -f 'build'",
"prebuild": "npm run clean && mkdir ./build",
"build": "npm run build:static && npm run build:js",
"build:dev": "npm run prebuild && npm run build:static && npm run build:jsDev",
"build:js": "browserify ./src/react.js -o ./build/app.js -t babelify -t [ envify purge --NODE_ENV production ] -t uglifyify",
"build:jsDev": "browserify ./src/react.js -o ./build/app.js -t babelify -t [ envify purge --NODE_ENV development ]",
"build:css": "NODE_PATH=. node-sass ./src/app.scss -o ./build -x --output-style compressed",
"build:static": "cp ./index.html ./build && npm run build:img && npm run build:css",
"build:data": "cp -r ./src/data ./build",
"build:img": "cp -r ./src/images ./build",
"watch": "npm run watch:js & npm run watch:css",
"watch:js": "watchify ./src/react.js -o ./build/app.js -t babelify -t [ envify purge --NODE_ENV development ] -dv",
"watch:css": "NODE_PATH=. node-sass ./src/app.scss -w ./src/**/*.scss -o ./build --output-style nested",
"test": "NODE_PATH=. mocha --compilers js:babel-core/register --reporter mocha-better-spec-reporter ${npm_package_config_ut}",
"test:single": "NODE_PATH=. mocha --compilers js:babel-core/register --reporter mocha-better-spec-reporter"
},
"author": "Hugo Di Francesco",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"babelify": "^7.3.0",
"browser-sync": "^2.16.0",
"browserify": "11.2.0",
"chai": "^3.5.0",
"envify": "^3.4.1",
"enzyme": "^2.4.1",
"mocha": "^3.0.2",
"mocha-better-spec-reporter": "^3.0.2",
"node-sass": "^3.10.0",
"react": "^15.3.0",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.3.0",
"uglifyify": "^3.0.3",
"watchify": "^3.7.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment