From 6d602399987ede66a509e7a8f0046c566bad9284 Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Thu, 17 Aug 2017 10:31:32 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20BundleAnalyzerPlugin=20in?= =?UTF-8?q?=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 2 +- src/webpack.config.js | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 21dd2eb..2fc6177 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -62,7 +62,7 @@ module.exports = function(config) { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: false, + singleRun: true, // Concurrency level // how many browser should be started simultaneous diff --git a/src/webpack.config.js b/src/webpack.config.js index ab38ff1..cfde318 100644 --- a/src/webpack.config.js +++ b/src/webpack.config.js @@ -6,7 +6,7 @@ var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlug var PROD = process.env.NODE_ENV === 'production'; var TEST = process.env.NODE_ENV === 'test'; -module.exports = { +var config = { entry: path.resolve('src/index.js'), output: { path: path.resolve('dist'), @@ -15,14 +15,7 @@ module.exports = { libraryTarget: 'umd', }, - externals: !TEST && [{ - 'react': { - root: 'React', - commonjs2: 'react', - commonjs: 'react', - amd: 'react', - }, - }], + externals: [], module: { loaders: [ @@ -53,8 +46,26 @@ module.exports = { new webpack.DefinePlugin({ EMOJI_DATASOURCE_VERSION: `'${pack.devDependencies['emoji-datasource']}'`, }), - new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false }) ], bail: true, } + +if (!TEST) { + config.externals = config.externals.concat([ + { + 'react': { + root: 'React', + commonjs2: 'react', + commonjs: 'react', + amd: 'react', + }, + }, + ]) + + config.plugins = config.plugins.concat([ + new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false }), + ]) +} + +module.exports = config