Skip to content

Commit 1185b3e

Browse files
committed
fix(cli): update wxss import code
1 parent 9137fad commit 1185b3e

File tree

1 file changed

+19
-10
lines changed
  • packages/cli/core/plugins/compiler

1 file changed

+19
-10
lines changed

packages/cli/core/plugins/compiler/index.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,25 @@ exports = module.exports = function () {
3030
let encoding = 'utf-8';
3131

3232
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+
}
4352
}
4453
}
4554
});

0 commit comments

Comments
 (0)