Describe the bug
docz does not work with SVGR. I get the following error:
Failed to execute 'createElement' on 'Document': The tag name provided ('/static/img/test.svg') is not a valid name.
To Reproduce
@svgr/webpack as dependency{
test: /\.svg$/,
use: {
loader: '@svgr/webpack',
options: {
icon: true
}
}
}
test.svg to the /svg folderindex.mdx file at the project root---
name: Icon
---
import { Playground } from 'docz'
import Icon from './svg/test.svg'
# Icon
<Playground>
<Icon />
</Playground>
docz...I also tested it with a modifyBundlerConfig with the same result.
modifyBundlerConfig: config => {
config.module.rules.push({
test: /\.svg$/,
use: {
loader: '@svgr/webpack',
options: {
icon: true
}
}
})
return config
}
Expected behavior
The icon is displayed.
Enviroment
Another test with svg-inline-loader produced the same error. Looks like a problem with webpack loaders.
By default we're using file-loader as svg loader, so what you can do is replace it to use svgr loader:
export default {
modifyBundlerConfig: config => {
const idx = config.module.rules.findIndex(
r => r.test.toString() === '/\\.(svg)(\\?.*)?$/'
)
config.module.rules[idx] = {
test: /\.svg$/,
use: {
loader: '@svgr/webpack',
},
}
return config
},
}
Thank you 馃尰
Now you can use the docz-plugin-svgr (1ac1ea8) plugin! 馃暫
Most helpful comment
By default we're using
file-loaderas svg loader, so what you can do is replace it to use svgr loader: