@@ -48,7 +48,7 @@ export default declare(({
4848 if ( typeof importPath !== 'string' ) {
4949 throw new TypeError ( '`applyPlugin` `importPath` must be a string' ) ;
5050 }
51- const { ignorePattern, caseSensitive, filename : providedFilename } = state . opts ;
51+ const { ignorePattern, caseSensitive, filename : providedFilename , root , alias } = state . opts ;
5252 const { file, filename } = state ;
5353 if ( ignorePattern ) {
5454 // Only set the ignoreRegex once:
@@ -61,10 +61,20 @@ export default declare(({
6161 // This plugin only applies for SVGs:
6262 if ( extname ( importPath ) === '.svg' ) {
6363 const iconPath = filename || providedFilename ;
64- const svgPath = resolve . sync ( importPath , { basedir : dirname ( iconPath ) } ) ;
65- if ( caseSensitive && ! fileExistsWithCaseSync ( svgPath ) ) {
66- throw new Error ( `File path didn't match case of file on disk: ${ svgPath } ` ) ;
64+ const aliasMatch = alias [ importPath . split ( '/' ) [ 0 ] ] ;
65+ let svgPath ;
66+
67+ if ( aliasMatch ) {
68+ const resolveRoot = resolve ( process . cwd ( ) , root || './' ) ;
69+ const aliasedPath = resolve ( resolveRoot , aliasMatch ) ;
70+ svgPath = aliasedPath + importPath . replace ( aliasMatch , '' ) ;
71+ } else {
72+ svgPath = resolve . sync ( importPath , { basedir : dirname ( iconPath ) } ) ;
73+ if ( caseSensitive && ! fileExistsWithCaseSync ( svgPath ) ) {
74+ throw new Error ( `File path didn't match case of file on disk: ${ svgPath } ` ) ;
75+ }
6776 }
77+
6878 if ( ! svgPath ) {
6979 throw new Error ( `File path does not exist: ${ importPath } ` ) ;
7080 }
0 commit comments