Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack-merge merge is not a function

In a new version of webpack-merge, It is imported like below.

const { merge } = require('webpack-merge');

As from version 5 of webpack-merge, the merge function is now named export instead of a default export.

Before version 5

const merge = require('webpack-merge');

From version 5

const merge = require('webpack-merge').merge;
// or       
const { merge } = require('webpack-merge');

If you are using ES modules, then you should do as:

import { merge } from "webpack-merge"

I use a ES6 webpack config, so I use [email protected] ...

import merge from "webpack-merge"

you can also leverage merge by renaming it like below:

const { merge: webpackMerge } = require("webpack-merge");

by this way you still using the same name of old api of the package!