-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from alemayhu/fix-webpack-sonar-issue
refactor: use conditional statement instead of switch
- Loading branch information
Showing
1 changed file
with
18 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |