Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 58674b6

Browse files
authored
Merge pull request #1 from DerekRoth/addDependency-support
Webpack addDependency support
2 parents e0d7b9d + 383eec6 commit 58674b6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/loader.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
const twing = require('twing');
2+
const path = require('path');
3+
4+
module.exports = async function loader() {
5+
const loader = new twing.TwingLoaderRelativeFilesystem();
6+
const tw = new twing.TwingEnvironment(loader);
7+
8+
tw.on('template', (tplName, from) => {
9+
from = from ? from : {path: ''};
10+
let toLoad = path.normalize(path.dirname(from.path) + '/' + tplName);
11+
this.addDependency(toLoad);
12+
});
213

3-
module.exports = function loader() {
414
try {
5-
const loader = new twing.TwingLoaderRelativeFilesystem();
6-
const tw = new twing.TwingEnvironment(loader);
7-
const html = tw.render(this.resource);
8-
return html;
15+
return await tw.render(this.resource);
916
}
1017
catch (e) {
1118
console.log(e);
1219
}
13-
}
20+
}

0 commit comments

Comments
 (0)