Reputation: 1301
I'm using require.context
to import all svg icons as react components like this
const req = require.context('@svgr/webpack!./library', true, /\.svg$/)
I want to be able to configure the loader like I could in my webpack config
{
test: /\.svg$/,
use: [{loader: '@svgr/webpack', options: {icon: true, svgo: true}}],
}
Is that possible in require.context?
Upvotes: 0
Views: 718
Reputation: 1877
From the webpack documentation:
Options can be passed with a query parameter, e.g. ?key=value&foo=bar, or a JSON object, e.g. ?{"key":"value","foo":"bar"}.
Try this (not tested):
const req = require.context('@svgr/webpack?icon&svgo!./library', true, /\.svg$/)
Upvotes: 1