@@ -30,16 +30,25 @@ exports = module.exports = function () {
30
30
let encoding = 'utf-8' ;
31
31
32
32
if ( this . assets . get ( importfile ) === undefined ) {
33
- // add assets dependencies
34
- this . assets . update ( importfile , {
35
- encoding : encoding ,
36
- source : new RawSource ( fs . readFileSync ( importfile , encoding ) ) ,
37
- } , { url : true , npm : ctx . npm } ) ;
38
-
39
- this . hookUnique ( 'wepy-compiler-wxss' , {
40
- content : fs . readFileSync ( importfile , encoding )
41
- } , Object . assign ( { } , ctx , { dep : true } ) ) ;
42
-
33
+ let importCode ;
34
+
35
+ try {
36
+ importCode = fs . readFileSync ( importfile , encoding ) ;
37
+ } catch ( e ) {
38
+ this . logger . warn ( 'compiler' , `Can not open file ${ importfile } in ${ ctx . file } ` ) ;
39
+ }
40
+
41
+ if ( importCode ) {
42
+ // add assets dependencies
43
+ this . assets . update ( importfile , {
44
+ encoding : encoding ,
45
+ source : new RawSource ( importCode ) ,
46
+ } , { url : true , npm : ctx . npm } ) ;
47
+
48
+ this . hookUnique ( 'wepy-compiler-wxss' , {
49
+ content : importCode
50
+ } , Object . assign ( { } , ctx , { dep : true } ) ) ;
51
+ }
43
52
}
44
53
}
45
54
} ) ;
0 commit comments