I want to replace all instances of
() => import('@/components/something/Something')
with
() => import(/* webpackChunkName: "components--something--Something" */ '@/components/something/Something')
So far I have this find/replace regex
Find: \(\) => import\('(.+?)'\)
Replace: () => import(/* webpackChunkName: "$1" */ '$1')
Which replaces:
() => import('@/components/something/Something')
with
() => import(/* webpackChunkName: "@/components/something/Something" */ '@/components/something/Something')
My problem is that I don't know how to replace the "@" and "/" characters
Do I need to execute two find/replace queries or can it be done with a single one? I want to remove the "@" entirely and replace the "/" by "--"
Any help much appreciated!
Thanks
With two find/replace:
find: (\(\) => import\()'@/([^']*)'\)
replace: $1/* webpackChunkName: "$2" */ '@/$2')
demo
and
find: ((?:\G(?!^)|\(\) => import\(/\*)[^/*]*)/
replace: $1--
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With