@@ -80,22 +80,34 @@ class CSSSource {
8080 }
8181
8282 public static fromURI ( uri : string , keyframes : KeyframesMap ) : CSSSource {
83+ // webpack modules require all file paths to be relative to /app folder.
84+ let appRelativeUri = uri ;
85+ if ( appRelativeUri . startsWith ( "/" ) ) {
86+ var app = knownFolders . currentApp ( ) . path + "/" ;
87+ if ( appRelativeUri . startsWith ( app ) ) {
88+ appRelativeUri = "./" + appRelativeUri . substr ( app . length ) ;
89+ }
90+ }
91+
8392 try {
84- const cssOrAst = global . loadModule ( uri ) ;
93+ const cssOrAst = global . loadModule ( appRelativeUri ) ;
8594 if ( cssOrAst ) {
8695 if ( typeof cssOrAst === "string" ) {
87- return CSSSource . fromSource ( cssOrAst , keyframes , uri ) ;
96+ // raw-loader
97+ return CSSSource . fromSource ( cssOrAst , keyframes , appRelativeUri ) ;
8898 } else if ( typeof cssOrAst === "object" && cssOrAst . type === "stylesheet" && cssOrAst . stylesheet && cssOrAst . stylesheet . rules ) {
89- return CSSSource . fromAST ( cssOrAst , keyframes , uri ) ;
99+ // css-loader
100+ return CSSSource . fromAST ( cssOrAst , keyframes , appRelativeUri ) ;
90101 } else {
91- // Probably a webpack css -loader exported object.
92- return CSSSource . fromSource ( cssOrAst . toString ( ) , keyframes , uri ) ;
102+ // css2json -loader
103+ return CSSSource . fromSource ( cssOrAst . toString ( ) , keyframes , appRelativeUri ) ;
93104 }
94105 }
95106 } catch ( e ) {
96107 //
97108 }
98- return CSSSource . fromFile ( uri , keyframes ) ;
109+
110+ return CSSSource . fromFile ( appRelativeUri , keyframes ) ;
99111 }
100112
101113 public static fromFile ( url : string , keyframes : KeyframesMap ) : CSSSource {
0 commit comments