Too many if statements

You could possibly use a dictionary. Dictionaries store references, which means functions are perfectly viable to use, like so: operationFuncs = { Operation.START: strategy_objects.StartObject Operation.STOP: strategy_objects.StopObject Operation.STATUS: strategy_objects.StatusObject (…) } It’s good to have a default operation just in case, so when you run it use a try except and handle the exception (ie. the … Read more

Conditional build based on environment using Webpack

You can use the define plugin. I use it by doing something as simple as this in your webpack build file where env is the path to a file that exports an object of settings: // Webpack build config plugins: [ new webpack.DefinePlugin({ ENV: require(path.join(__dirname, ‘./path-to-env-files/’, env)) }) ] // Settings file located at `path-to-env-files/dev.js` … Read more