babel-plugin-inline-react-svg
babel-plugin-inline-react-svg copied to clipboard
Support passing an alias object to fix issues with babel module resolver
Given a .babelrc like this
{
"presets": ["next/babel"],
"plugins": [
["inline-react-svg", {
"root": "./",
"alias": {
"svgs": "svgs"
}
}],
["module-resolver", {
"root": ["./"],
"alias": {
"svgs": "svgs"
}
}]
]
}
Supports basically the same syntax as module-resolver but root has to be a string not an array
Closes #14
Let me know what do you think
This one need to be merged @kesne
@kesne Would it be possible to get this merged. Thanks!
@Zaggen This looks great, any chance you can rebase on master?
@kesne Did a rebase, but I din't get a chance to properly check if it doesn't break the functionality, I'll make the changes with the root property as soon as I have time and then you can confirm if everything is ok
Anything I can do to help move this PR along? Seems like there hasn't been any activity in a while but the functionality seems super useful.
I've got a working branch based on this PR, just haven't gotten around to submitting it. https://github.com/OscarBarrett/babel-plugin-inline-react-svg/tree/feature/resolve
With an example config being
['babel-plugin-inline-react-svg', {
root: path.resolve(__dirname, 'src'),
alias: {
images: 'images'
}
}],
IIRC resolve and resolveFrom didn't seem to work properly so in my branch I switched to path's version.
@OscarBarrett Could you delivery package since airbnb is sleeping
You can bypass the problem in typescript by reexporting
import AppStore from '../static/appstore.svg' export { AppStore }
then just import {AppStore} from 'styles'
@patsadow2 nobody's "sleeping".
I've pulled in @OscarBarrett's rebased branch. This will still need tests.
Hi guys, as of now, a nextjs project with svg, absolute path and Typescript cant import a svg like import Logo from '~/assets/Logo.svg' and it looks like this PR tried to solve it.
Is this still happening?
when it will be merged?
@vavilondev when someone posts a link to a branch that contains tests.