-
Notifications
You must be signed in to change notification settings - Fork 36
/
extra-webpack.config.js
43 lines (39 loc) · 1.09 KB
/
extra-webpack.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
const PerspectivePlugin = require('@finos/perspective-webpack-plugin');
module.exports = (config, options) => {
config.plugins.push(
new PerspectivePlugin(),
/* temp fix to remove source map loader added by perspective plugin which causes compilation warnings */
{
apply(compiler) {
compiler.hooks.afterPlugins.tap(
'PerspectiveConfigFixerPlugin',
removePerspectiveSourceMapLoader
);
},
}
);
return config;
};
function removePerspectiveSourceMapLoader(compiler) {
const rules = (((compiler || {}).options || {}).module || {}).rules || [];
const ruleIndex = rules.findIndex(isPerspectiveSourceMapLoaderRule);
if (ruleIndex > -1) {
rules.splice(ruleIndex, 1);
}
}
function isSameRegex(regex1, regex2) {
return (
regex1 instanceof RegExp &&
regex2 instanceof RegExp &&
regex1.source === regex2.source
);
}
const matchRegex = /\.js$/;
function isPerspectiveSourceMapLoaderRule(rule) {
return (
rule &&
rule.loader === 'source-map-loader' &&
rule.test &&
isSameRegex(matchRegex, rule.test)
);
}