Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
configure: (webpackConfig) => {
const lm = getLoader(webpackConfig, loaderByName('babel-loader'));
const loader = lm.match.loader;
webpackConfig.module.rules[2].oneOf[1] = transformBabelLoader(loader);
return webpackConfig;
}
}
}
});
} else {
throwError(
`Found an unhandled loader in the ${context.env} webpack config: ${rule.loader}`,
"webpack+unknown+rule"
);
}
});
if (pluginOptions.modifyLessRule) {
lessRule = pluginOptions.modifyLessRule(lessRule, context);
}
oneOfRule.oneOf.push(lessRule);
const { isFound, match: fileLoaderMatch } = getLoader(
webpackConfig,
loaderByName("file-loader")
);
if (!isFound) {
throwError(
`Can't find file-loader in the ${context.env} webpack config!`,
"webpack+file-loader"
);
}
fileLoaderMatch.loader.exclude.push(lessExtension);
return webpackConfig;
};
const throwError = (message, githubIssueQuery) =>
throwUnexpectedConfigError({
packageName: 'craco-linaria',
githubRepo: 'jedmao/craco-linaria',
message,
githubIssueQuery,
})
if (!webpackConfig.module) {
throwError(
`Can't find 'module' key in the ${context.env} webpack config!`,
'webpack+module',
)
}
const { isFound, match: babelLoaderMatch } = getLoader(
webpackConfig,
loaderByName('babel-loader'),
)
if (!isFound) {
throwError(
`Can't find babel-loader in the ${context.env} webpack config!`,
'webpack+babel-loader',
)
}
const oneOfRules = webpackConfig.module.rules.find(rule => rule.oneOf)
if (!oneOfRules) {
throwError(
`Can't find 'oneOf' rules under module.rules in the ${context.env} webpack config!`,
'webpack+rules+oneOf',
overrideWebpackConfig: ({ context, webpackConfig }) => {
const { isFound, match: fileLoaderMatch } = getLoader(
webpackConfig,
loaderByName("file-loader")
);
if (!isFound) {
throwUnexpectedConfigError({
message: `Can't find file-loader in the ${context.env} webpack config!`
});
}
fileLoaderMatch.loader.exclude.push(/theme.config$/);
fileLoaderMatch.loader.exclude.push(/\.variables$/);
fileLoaderMatch.loader.exclude.push(/\.overrides$/);
return webpackConfig;
}