Reputation:
I have trying to add react in the shopify theme. So configured react, webpack, babel manually. Webpack.dev.js
const merge = require('webpack-merge');
const common = require("./webpack.common.js")
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
watch: true
})
But I am getting error, merge is not a function. Thanks in advance.
Upvotes: 41
Views: 27374
Reputation: 86
I have imported like below,
const { merge } = require("webpack-merge");
and used as
const mergedConfig = merge(config, customConfig);
Upvotes: 0
Reputation: 25406
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"
Upvotes: 14
Reputation: 7460
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!
Upvotes: 1
Reputation: 101
I use a ES6 webpack config, so I use [email protected] ...
import merge from "webpack-merge"
Upvotes: 4
Reputation: 1296
In a new version of webpack-merge, It is imported like below.
const { merge } = require('webpack-merge');
Upvotes: 104