File tree 2 files changed +4
-2
lines changed
2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 43
43
"babel-traverse" : " ^6.15.0" ,
44
44
"babylon" : " ^6.10.0" ,
45
45
"lodash.isplainobject" : " ^4.0.6" ,
46
+ "resolve-from" : " ^2.0.0" ,
46
47
"svgo" : " ^0.7.0"
47
48
}
48
49
}
Original file line number Diff line number Diff line change 1
- import { extname , dirname , join } from 'path' ;
1
+ import { extname , dirname } from 'path' ;
2
2
import { readFileSync } from 'fs' ;
3
3
import template from 'babel-template' ;
4
4
import traverse from 'babel-traverse' ;
5
5
import { parse } from 'babylon' ;
6
+ import resolveFrom from 'resolve-from' ;
6
7
import optimize from './optimize' ;
7
8
import transformSvg from './transformSvg' ;
8
9
@@ -29,7 +30,7 @@ export default ({ types: t }) => ({
29
30
// We only support the import default specifier, so let's use that identifier:
30
31
const importIdentifier = path . node . specifiers [ 0 ] . local ;
31
32
const iconPath = state . file . opts . filename ;
32
- const svgPath = join ( dirname ( iconPath ) , path . node . source . value ) ;
33
+ const svgPath = resolveFrom ( dirname ( iconPath ) , path . node . source . value ) ;
33
34
const svgSource = readFileSync ( svgPath , 'utf8' ) ;
34
35
const optimizedSvgSource = optimize ( svgSource ) ;
35
36
You can’t perform that action at this time.
0 commit comments