From 32a13b4c14518264703c9b292eadd2bc6e92fb3d Mon Sep 17 00:00:00 2001 From: Gioele Masini Date: Tue, 6 Sep 2016 13:00:26 +0200 Subject: [PATCH] [Update] Added babel-plugin-istanbul to substitute isparta-loader (deprecated). --- package.json | 2 +- webpack.config.js | 39 +++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index bd8f95c75..c6633b084 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,13 @@ "autoprefixer": "^6.0.3", "babel-core": "^6.2.1", "babel-loader": "^6.2.0", + "babel-plugin-istanbul": "^2.0.1", "babel-preset-es2015": "^6.1.18", "copy-webpack-plugin": "^3.0.1", "css-loader": "^0.23.0", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.9.0", "html-webpack-plugin": "^2.7.1", - "isparta-loader": "^2.0.0", "jasmine-core": "^2.3.4", "karma": "^1.1.0", "karma-coverage": "^1.0.0", diff --git a/webpack.config.js b/webpack.config.js index 519c3bb30..f23e0bc73 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -69,6 +69,27 @@ module.exports = function makeWebpackConfig () { config.devtool = 'eval-source-map'; } + /** + * Babel query options + * Reference: https://github.com/babel/babel-loader#options + * https://github.com/istanbuljs/babel-plugin-istanbul + * Instrument JS files with babel-plugin-istanbul for subsequent code coverage reporting + * Skips files that end with .spec.js + */ + var babelQueryOptions = null; + if (isTest) { + babelQueryOptions = { + plugins: [ + [ + 'istanbul', + { + exclude: [ '**/*.spec.js' ] + } + ] + ] + } + } + /** * Loaders * Reference: http://webpack.github.io/docs/configuration.html#module-loaders @@ -86,7 +107,8 @@ module.exports = function makeWebpackConfig () { // Compiles ES6 and ES7 into ES5 code test: /\.js$/, loader: 'babel', - exclude: /node_modules/ + exclude: /node_modules/, + query: babelQueryOptions }, { // CSS LOADER // Reference: https://github.com/webpack/css-loader @@ -119,21 +141,6 @@ module.exports = function makeWebpackConfig () { }] }; - // ISPARTA LOADER - // Reference: https://github.com/ColCh/isparta-instrumenter-loader - // Instrument JS files with Isparta for subsequent code coverage reporting - // Skips node_modules and files that end with .test.js - if (isTest) { - config.module.preLoaders.push({ - test: /\.js$/, - exclude: [ - /node_modules/, - /\.spec\.js$/ - ], - loader: 'isparta-loader' - }) - } - /** * PostCSS * Reference: https://github.com/postcss/autoprefixer-core