I'd like to add SVGs to the file-loader exclude list so I can use a custom loader with them. Currently I'm doing appConfig.module.rules[2].exclude.push(/\.svg$/);
in my razzle.config.js
but obviously that's a bit hacky! Is there a better way?
I've run into a similar issue where I want to introduce a new loader that isn't covered by the default exclude
list of file-loader
.
I've tried adding my loader at the bottom, _(which is how Webpack says priority works)_ but it still seems to go through the file-loader
. Adding the extension of the file to the exclude list using the same method as @superfunkminister solves the issues and means my loader works as expected.
I'd also like a way to modify the exclude
list without having to assume the position of the loader in the config.module.rules
array.
I just had this issue too. If anyone still needs this, the official plugins seem to do it the following way:
const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
config.module.rules[
config.module.rules.findIndex(makeLoaderFinder('file-loader'))
].exclude.push(/\.graphql$/);
@jaredpalmer I think it would make a lot of sense to document this somewhere visible because the fact that all unknown files are automatically caught by file-loader can be quite confusing. What do you think?
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.
Most helpful comment
I just had this issue too. If anyone still needs this, the official plugins seem to do it the following way:
@jaredpalmer I think it would make a lot of sense to document this somewhere visible because the fact that all unknown files are automatically caught by file-loader can be quite confusing. What do you think?