How to use the webpack-merge/lib/join-arrays-smart.uniteRules.bind 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
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);
      });

      return [..._.unionWith(a, preAndPostRules, uniteRules.bind(null, {}, key)), oneOfRule];
    } else if (key === "externals") {
      return [...b, ...a];
    }

    // Fall back to default merging
    return undefined;
  },