-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathwebpack.dev-coverage.config.js
More file actions
41 lines (35 loc) · 1.27 KB
/
webpack.dev-coverage.config.js
File metadata and controls
41 lines (35 loc) · 1.27 KB
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
/* eslint-disable @typescript-eslint/no-require-imports */
/**
* Extends fec's dev-proxy webpack config to add Istanbul instrumentation.
* Use with: yarn local:coverage
*/
const path = require('path');
// Load fec's original dev-proxy config
const originalConfigPath = path.join(
__dirname,
'node_modules/@redhat-cloud-services/frontend-components-config/bin/dev-proxy.webpack.config.js'
);
const originalConfig = require(originalConfigPath);
// Add Istanbul instrumentation when COVERAGE=true
if (process.env.COVERAGE === 'true') {
console.log('📊 Coverage mode enabled - adding Istanbul instrumentation');
originalConfig.module = originalConfig.module || {};
originalConfig.module.rules = originalConfig.module.rules || [];
originalConfig.module.rules.push({
test: /\.(ts|tsx|js|jsx)$/,
include: path.resolve(__dirname, 'src'),
exclude: /node_modules|\.test\.|\.spec\./,
enforce: 'post',
use: {
loader: '@jsdevtools/coverage-istanbul-loader',
options: {
esModules: true,
// Use window directly instead of new Function("return this")()
// This avoids CSP issues in the browser
coverageGlobalScope: 'window',
coverageGlobalScopeFunc: false,
},
},
});
}
module.exports = originalConfig;