-
Notifications
You must be signed in to change notification settings - Fork 139
/
webpack.test.config.js
47 lines (43 loc) · 1.12 KB
/
webpack.test.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const glob = require('glob');
const path = require('path');
const moduleConfig = require('./webpack.config').module;
if (shouldInstrument()) {
moduleConfig.rules.find(rule => {
const loader = rule.use.find(use => use.loader === 'babel-loader')
if (!loader) return;
loader.options.plugins.push('istanbul');
});
}
module.exports = {
entry: glob.sync('./test/unit/**/*.test.js'),
mode: 'development',
output: {
path: path.join(__dirname, 'build'),
publicPath: '/build/',
filename: 'test-unit.js'
},
module: moduleConfig,
resolve: {
extensions: ['.js', '.json'],
modules: [
path.join(__dirname, 'test'),
'node_modules'
]
},
plugins: [
new MiniCssExtractPlugin({ filename: 'recurly.css' }),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
devtool: 'inline-source-map'
};
// Only instrument in CI if we're set to report coverage
function shouldInstrument () {
if (process.env.CI) {
return !!process.env.REPORT_COVERAGE;
}
return true;
}