webpackFinal: async (config) => {
config.resolve.plugins.push(new TsconfigPathsPlugin({}));
return config;
},
TypeError: Cannot read property 'push' of undefined
The error occurred after upgrading. from webpack4
to webpack5
.
webpackFinal: async (config) => {
if (config.resolve.plugins !== undefined) {
config.resolve.plugins.push(new TsconfigPathsPlugin({}));
} else {
config.resolve.plugins = [new TsconfigPathsPlugin({})];
}
return config;
},
I thought that config.resolve.plugins
is possible to be not undefined
in the future. This is why I first checked whether config.resolve.plugins
is undefined or not then replace config.resolve.plugins
or push the plugin into config.resolve.plugins
.
Top comments (0)