@@ -14,7 +14,7 @@ class Options {
1414 defaults : Models . Defaults ;
1515 constructor ( optsObj : Object ) {
1616 this . vueFileRegex = / ( [ \w / . \- @ _ \d ] * \. v u e ) / igm;
17- this . requireRegex = / ( r e q u i r e \( ' ) ( [ \w / . \- @ _ \d ] * \. v u e ) ( ' \) ) / igm;
17+ this . requireRegex = / ( r e q u i r e \( [ ' " ] ) ( [ \w / . \- @ _ \d ] * \. v u e ) ( [ ' " ] \) ) / igm;
1818 this . appendPaths = optsObj . appendPaths || [ ] ;
1919 this . prependPaths = optsObj . prependPaths || [ ] ;
2020 this . rootPath = optsObj . rootPath || '' ;
@@ -46,18 +46,30 @@ function getVueObject(componentPath: string, rootPath: string, vueComponentFileM
4646}
4747
4848function replaceRelativePaths ( code : string , rootPath : string ) : string {
49- const parentMatches = code . match ( / ( r e q u i r e \( ' \. \. \/ ) / gm) ;
50- const currentMatches = code . match ( / ( r e q u i r e \( ' \. \/ ) / gm) ;
51- if ( parentMatches ) {
52- for ( const match of parentMatches ) {
49+ const parentMatchesSingle = code . match ( / ( r e q u i r e \( ' \. \. \/ ) / gm) ;
50+ const currentMatchesSingle = code . match ( / ( r e q u i r e \( ' \. \/ ) / gm) ;
51+ const parentMatchesDouble = code . match ( / ( r e q u i r e \( " \. \. \/ ) / gm) ;
52+ const currentMatchesDouble = code . match ( / ( r e q u i r e \( " \. \/ ) / gm) ;
53+ if ( parentMatchesSingle ) {
54+ for ( const match of parentMatchesSingle ) {
5355 code = code . replace ( match , `require('${ rootPath } /../` ) ;
5456 }
5557 }
56- if ( currentMatches ) {
57- for ( const match of currentMatches ) {
58+ if ( parentMatchesDouble ) {
59+ for ( const match of parentMatchesDouble ) {
60+ code = code . replace ( match , `require("${ rootPath } /../` ) ;
61+ }
62+ }
63+ if ( currentMatchesSingle ) {
64+ for ( const match of currentMatchesSingle ) {
5865 code = code . replace ( match , `require('${ rootPath } /./` ) ;
5966 }
6067 }
68+ if ( currentMatchesDouble ) {
69+ for ( const match of currentMatchesDouble ) {
70+ code = code . replace ( match , `require("${ rootPath } /./` ) ;
71+ }
72+ }
6173
6274 return code ;
6375}
0 commit comments