Skip to content

Instantly share code, notes, and snippets.

@luk3thomas
Last active December 27, 2015 03:42
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 luk3thomas/c6d608fc17b1a8e4781b to your computer and use it in GitHub Desktop.
Save luk3thomas/c6d608fc17b1a8e4781b to your computer and use it in GitHub Desktop.
This is the typical setup I use when I create a JS library.

Setup

npm install --save-dev babel-core \
  babel-loader \
  babel-preset-es2015 \
  eslint \
  eslint-config-airbnb \
  imports-loader \
  jasmine \
  karma \
  karma-eslint \
  karma-jasmine \
  karma-phantomjs-launcher \
  karma-webpack \
  phantomjs \
  sinon \
  webpack

.eslintrc

{ "extends": "airbnb/base"
, "rules":
  { "func-names": 0
  , "no-undef": 0
  }
}

karma.config.js

module.exports = function(config) {
  config.set({
    frameworks: [ 'jasmine' ],

    files: [
      'test/**/*_test*'
    ],

    preprocessors: {
      'test/**/*_test*': 'webpack'
    },

    webpack: {
      module: {
        loaders: [
          { test: /js$/
          , loader: 'babel'
          , exclude: /node_modules/
          , query: { presets: ['es2015'] }
          }
        ]
      }
    },

    webpackMiddleware: {
      noInfo: true
    }
  });
};

webpack.config.js

module.exports =
{ entry: './src/index.js'
, module:
  { loaders:
    [ { test: 'js$'
      , exclude: /node_modules/
      , loader: 'babel'
      , query: { presets: ['es2015'] }
      }
    ]
  }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment