How to use the webpack-merge/lib/join-arrays-smart.uniteRules function in webpack-merge

To help you get started, we’ve selected a few webpack-merge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / tools / webpack / config / helpers.js View on Github external
if (resource.startsWith(knownDir))
      return true;
  }

  const dir = path.dirname(resource);
  const matches = glob.sync(path.join(dir, "{!(module)/**/*.map,*.map}"));
  if (matches && matches.length > 0) {
    knownSourceMapPaths.push(dir);
    return true;
  }
  return false;
};

const _ = require("lodash");
const merge = require("webpack-merge");
const uniteRules = require("webpack-merge/lib/join-arrays-smart").uniteRules;

const mergeWdioConfigs = merge;
const mergeWebpackConfigs = merge({
  customizeArray: (a, b, key) => {
    if (key === "module.rules") {
      const preAndPostRules = [];
      const oneOfRule = a.pop();
      if (!oneOfRule.oneOf)
        throw new Error("Failed to merge webpack configs.  The last entry in a base config's module.rules must be { oneOf: [...] }.");

      b.forEach(rule => {
        if (rule.enforce)
          preAndPostRules.push(rule);
        else
          oneOfRule.oneOf.unshift(rule);
      });