Forked from sam-artuso/setting-up-babel-nodemon.md
Last active
September 13, 2018 09:57
-
-
Save andyfoster/d2d96050e3a37b042a2eefb00c58653e to your computer and use it in GitHub Desktop.
Revisions
-
andyfoster revised this gist
Sep 13, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,8 +66,8 @@ Add this line to the `scripts` section in `package.json`: ```json "scripts": { ... "mocha": "mocha --require babel-core/register", "test": "mocha --require babel-core/register --recursive ./test/" } ``` -
Sam Artuso revised this gist
Nov 7, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,7 +66,8 @@ Add this line to the `scripts` section in `package.json`: ```json "scripts": { ... "mocha": "mocha --compilers js:babel-register", "test": "mocha --compilers js:babel-register --recursive ./test/" } ``` -
Sam Artuso revised this gist
Nov 7, 2016 . 1 changed file with 51 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,53 +5,87 @@ Set up project: ```bash mkdir project cd project npm init -y ``` Install dev dependencies: ```bash npm i --save-dev babel-cli babel-preset-latest nodemon ``` Configure Babel by adding the lines below to `package.json`: ```json "babel": { "presets": [ "latest" ] }, ``` ### Scripts Add some convenience scripts to `package.json`: ```json "scripts": { "babel-node": "babel-node --presets=latest", "start": "nodemon --exec npm run babel-node -- ./index.js", "build": "babel src -d dist" }, ``` To start the Node.js REPL: ```bash npm run babel-node ``` To start the app in development mode (letting Babel interpret ES6 code): ```bash npm start ``` To build the ES5 code in the `build` directory from the ES6 code in the `src` directory: ```bash npm build ``` ### Adding in `Mocha` and `chai` ```bash npm install --save-dev mocha chai ``` Add this line to the `scripts` section in `package.json`: ```json "scripts": { ... "test": "mocha --compilers js:babel-register --recursive" } ``` Create a new directory called `test`: ```bash mkdir test ``` Minimal test (to save e.g. as `test/test.js`): ```javascript 'use strict' import { expect } from 'chai' describe('test', function () { it('should pass', function () { expect('string').to.be.a('string') }) }) ``` -
Sam Artuso revised this gist
Oct 22, 2016 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,9 @@ Set up project: Install dev dependencies: ```bash npm i --save-dev babel-cli babel-preset-latest nodemon ``` Configure Babel by adding the lines below to `package.json`: @@ -38,12 +40,18 @@ Add some convenience scripts to `package.json`: To start the Node.js REPL: ```bash npm run babel-node ``` To start the app in development mode (letting Babel interpret ES6 code): ```bash npm start ``` To build the ES5 code in the `build` directory from the ES6 code in the `src` directory: ```bash npm build ``` -
Sam Artuso revised this gist
Oct 22, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,11 @@ Set up project: ```bash mkdir project cd project npm init -y ``` Install dev dependencies: -
Sam Artuso renamed this gist
Oct 22, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Sam Artuso created this gist
Oct 22, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ ## Setting up Babel and nodemon ### Inital set-up Set up project: mkdir project cd project npm init -y Install dev dependencies: npm i --save-dev babel-cli babel-preset-latest nodemon Configure Babel by adding the lines below to `package.json`: ```json "babel": { "presets": [ "latest" ] }, ``` ### Scripts Add some convenience scripts to `package.json`: ```json "scripts": { "babel-node": "babel-node --presets=latest", "start": "nodemon --exec npm run babel-node -- ./index.js", "build": "babel src -d dist" }, ``` To start the Node.js REPL: npm run babel-node To start the app in development mode (letting Babel interpret ES6 code): npm start To build the ES5 code in the `build` directory from the ES6 code in the `src` directory: npm build