Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
overrideWebpackConfig: ({ webpackConfig }) => {
// Search for all instances of babel-loader.
const { hasFoundAny, matches } = getLoaders(
webpackConfig,
loaderByName("babel-loader")
);
// If we can't find the loader then throw an error.
if (!hasFoundAny) {
throw new Error("could not find babel-loader");
}
let hasFoundRightLoader = false;
// Loop through each match, enabling babelrc and clearing any presets.
matches.forEach(({ loader }) => {
if (loader.test.toString() === /\.(js|mjs|jsx|ts|tsx)$/.toString()) {
hasFoundRightLoader = true;
if (!loader.options) {