reactjs - How to setup an app using browserify, babel, eslint, react/jsx, and jest (no gulp/grunt)? -
i setup app using
- browserify
- babeljs
- eslint
- react(with jsx)
- jest
npm task manager (no gulp|grunt|brocoli)
first of need install libraries npm
.
npm install --save-dev eslint, browserify, babelify, jest-cli
the package names self explain lib installed.
browserify:
assuming app/index.js
root file. can add following scripts build , watch source file.
"scripts": { "build": "browserify app/index.js > public/js/bundle.js", "install": "npm run build", "watch": "watchify app/index.js -o public/js/bundle.js" }
es6 , jsx
to compile es6 , jsx, add following package.json
:
"browserify": { "transform": [ "babelify" ] }
now, browserify transforms es6 , jsx syntax plain javascript 5. more transformations check out https://github.com/substack/node-browserify/wiki/list-of-transforms.
jest
to use jest add following package.json.
"scripts": { "test": "" }
after that, can run tests using npm test
. jest documentation
eslint
if it's first time using eslint, should set config file using eslint --init
, need add new script package.json
.
for example:
"lint" : "eslint app/*.js"
note, need specify source files want lint in above command.
Comments
Post a Comment