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

What is the difference between require(‘mypackage.js’) and require(‘mypackage’)?

Here is the answer: Module.prototype.load = function(filename) { debug(‘load ‘ + JSON.stringify(filename) + ‘ for module ‘ + JSON.stringify(this.id)); assert(!this.loaded); this.filename = filename; this.paths = Module._nodeModulePaths(path.dirname(filename)); var extension = path.extname(filename) || ‘.js’; if (!Module._extensions[extension]) extension = ‘.js’; Module._extensions[extension](this, filename); this.loaded = true; }; Node.JS looks to see if the given module is a core module. … Read more