Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import path from 'path';
import enhancedResolve from 'enhanced-resolve';
import isRequestInRequestMap from './isRequestInRequestMap';
const resolveLoaderSync = enhancedResolve.loader.sync;
export default (context: string, requestMap: Object, request: string, parentFilename: string): any => {
const loaders = request.split('!');
const requestFilePath = loaders.pop();
const resolvedLoaders = loaders
.map((loader: string): string => {
// @todo What is the purpose of the context parameter?
return resolveLoaderSync({}, parentFilename, loader);
})
.map((loaderAbsolutePath: string): string => {
return path.relative(context, loaderAbsolutePath);
});
const absoluteRequestPath = path.resolve(path.dirname(parentFilename), requestFilePath);
const relativeTargetResourcePath = './' + path.relative(context, absoluteRequestPath);