-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.test.js
36 lines (32 loc) · 1.01 KB
/
webpack.config.test.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
const path = require('path');
const buildConfig = require('./webpack.config.js');
const istanbulIncludes = [];
buildConfig.resolve.modules.forEach((relativePath) => {
if (relativePath.indexOf('node_modules') === -1) {
istanbulIncludes.push(path.resolve(relativePath));
}
});
buildConfig.resolve.modules.push('test');
const testConfig = {
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [require('webpack-node-externals')()], // in order to ignore all modules in node_modules folder
devtool: 'inline-cheap-module-source-map',
resolve: buildConfig.resolve,
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader'
},
{
test: /\.(js|ts)/,
include: istanbulIncludes, // instrument only testing sources with Istanbul, after ts-loader runs
loader: 'istanbul-instrumenter-loader',
options: {
esModules: true
}
}
]
}
};
module.exports = testConfig;