Skip to content

Instantly share code, notes, and snippets.

@TheLarkInn
Created July 9, 2018 12:06
Show Gist options
  • Save TheLarkInn/684bcdb5cf3a082c5a3cee907168c59a to your computer and use it in GitHub Desktop.
Save TheLarkInn/684bcdb5cf3a082c5a3cee907168c59a to your computer and use it in GitHub Desktop.
Load Preset
const webpackMerge = require("webpack-merge");
const applyPresets = (env = { presets: [] }) => {
const presets = env.presets || [];
/** @type {string[]} */
const mergedPresets = [].concat(...[presets]);
const mergedConfigs = mergedPresets.map(presetName => require(`./presets/webpack.${presetName}`)(env));
return webpackMerge({}, ...mergedConfigs);
};
module.exports = applyPresets;
@LinKassem
Copy link

@TheLarkInn, can you please provide a full example on how this can be used with the webpack.config.js ? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment