Skip to content

Instantly share code, notes, and snippets.

@andyfoster
Forked from sam-artuso/setting-up-babel-nodemon.md
Last active September 13, 2018 09:57
Show Gist options
  • Save andyfoster/d2d96050e3a37b042a2eefb00c58653e to your computer and use it in GitHub Desktop.
Save andyfoster/d2d96050e3a37b042a2eefb00c58653e to your computer and use it in GitHub Desktop.

Revisions

  1. andyfoster revised this gist Sep 13, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions setting-up-babel-nodemon.md
    Original 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 --compilers js:babel-register",
    "test": "mocha --compilers js:babel-register --recursive ./test/"
    "mocha": "mocha --require babel-core/register",
    "test": "mocha --require babel-core/register --recursive ./test/"
    }
    ```

  2. Sam Artuso revised this gist Nov 7, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setting-up-babel-nodemon.md
    Original 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": {
    ...
    "test": "mocha --compilers js:babel-register --recursive"
    "mocha": "mocha --compilers js:babel-register",
    "test": "mocha --compilers js:babel-register --recursive ./test/"
    }
    ```

  3. Sam Artuso revised this gist Nov 7, 2016. 1 changed file with 51 additions and 17 deletions.
    68 changes: 51 additions & 17 deletions setting-up-babel-nodemon.md
    Original file line number Diff line number Diff line change
    @@ -5,53 +5,87 @@
    Set up project:

    ```bash
    mkdir project
    cd project
    npm init -y
    mkdir project
    cd project
    npm init -y
    ```

    Install dev dependencies:

    ```bash
    npm i --save-dev babel-cli babel-preset-latest nodemon
    npm i --save-dev babel-cli babel-preset-latest nodemon
    ```

    Configure Babel by adding the lines below to `package.json`:

    ```json
    "babel": {
    "presets": [
    "latest"
    ]
    },
    "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"
    },
    "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
    npm run babel-node
    ```

    To start the app in development mode (letting Babel interpret ES6 code):

    ```bash
    npm start
    npm start
    ```

    To build the ES5 code in the `build` directory from the ES6 code in the `src` directory:

    ```bash
    npm build
    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')
    })
    })
    ```
  4. Sam Artuso revised this gist Oct 22, 2016. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion setting-up-babel-nodemon.md
    Original 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:

    npm build
    ```bash
    npm build
    ```
  5. Sam Artuso revised this gist Oct 22, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions setting-up-babel-nodemon.md
    Original 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:

  6. Sam Artuso renamed this gist Oct 22, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. Sam Artuso created this gist Oct 22, 2016.
    47 changes: 47 additions & 0 deletions gistfile1.txt
    Original 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