Skip to content

Commit

Permalink
Merge pull request #493 from alemayhu/fix-webpack-sonar-issue
Browse files Browse the repository at this point in the history
refactor: use conditional statement instead of switch
  • Loading branch information
aalemayhu authored Mar 5, 2022
2 parents 655df43 + 2d3de89 commit 10bc9fd
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions web/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
/* config-overrides.js */
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');

const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");

module.exports = function override(config) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(
new MonacoWebpackPlugin()
);
switch (process.env.NODE_ENV) {
case 'production':
config.plugins = config.plugins.filter(plugin => {
return plugin.constructor.name !== 'ForkTsCheckerWebpackPlugin';
});
return config;
default:
let forkTsCheckerWebpackPlugin = config.plugins.find(plugin => {
return plugin.constructor.name === 'ForkTsCheckerWebpackPlugin';
});
forkTsCheckerWebpackPlugin.memoryLimit = 4096;
return config;
}
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(new MonacoWebpackPlugin());
if (process.env.NODE_ENV === "production") {
config.plugins = config.plugins.filter((plugin) => {
return plugin.constructor.name !== "ForkTsCheckerWebpackPlugin";
});
return config;
}

let forkTsCheckerWebpackPlugin = config.plugins.find((plugin) => {
return plugin.constructor.name === "ForkTsCheckerWebpackPlugin";
});
forkTsCheckerWebpackPlugin.memoryLimit = 4096;
return config;
};
// Ref https://github.com/microsoft/monaco-editor/issues/82
// Ref https://www.gitmemory.com/issue/facebook/create-react-app/7135/497102755
// Ref https://www.gitmemory.com/issue/facebook/create-react-app/7135/497102755

0 comments on commit 10bc9fd

Please sign in to comment.