Skip to content

Instantly share code, notes, and snippets.

@abidibo
Last active January 13, 2017 13:42
Show Gist options
  • Save abidibo/4689e858aa33a1e18d48e94bf027bde9 to your computer and use it in GitHub Desktop.
Save abidibo/4689e858aa33a1e18d48e94bf027bde9 to your computer and use it in GitHub Desktop.
Node dev

Node Development gotchas

Init Project

npm init

Install packages

Production package (jQuery, react...)

npm install mypackage --save

Only development package (test suites, dev toolbars...)

npm install mypackage --save-dev

Webpack

Why I name the conf file webpack.config.babel.js and not webpack.config.js?

In order to use es6 inside webpack config! Requires babel-register

How to inject compiled js into html?

Use html-webpack-plugin

Linting

ESLint

Install it, babel-eslint is used to lint babel code
Add a lint entry to the package.json:

{  
    "name": "smartbox",
    ...,
    "scripts": {    
        ...,
        "lint": "./node_modules/eslint/bin/eslint.js ."
    },
    "author": "abidibo",
    ...
}

Run with

$ npm run lint

Enable trailing comma

In .eslintrc

  "rules": {
      ...,
      "comma-dangle": [2, "only-multiline"],
      ...,
  }

Vim? https://github.com/mtscout6/syntastic-local-eslint.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment