We have a bunch of video files that were deployed with the webpack code (stored in LFS)
We've moved them out to CDN and want to use the webpack file-loader with publicPath to convert them to absolute urls during build.
Webpack barfs because the file doesn't exist. This is my attempt at writing a resolve plugin to skip them, but i still get file not found errors.... What am i missing?
var VideoResolver = {
apply: function(resolver) {
const target = resolver.ensureHook("resolved");
resolver.getHook("module").tapAsync("VideoResolver", (request, resolveContext, callback) => {
if (request.request.startsWith("assets/videos") || request.request.endsWith(".mp4")) {
const resolved = {
path: request.request,
request: request.request,
query: request.query,
resolveToContext:{},
directory: !request.request.endsWith(".mp4")
};
console.log(resolved)
resolver.doResolve(
target,
resolved,
`skipping video resolve for ${request.request}`,
resolveContext,
callback
);
} else {
callback();
}
});
},
};
Edit: Looks like the NormalModule and LoaderRunner read the content of files and pass it to the loaders (which seem badly named :) ). I can't see an easy way to override this behaviour