-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (38 loc) · 819 Bytes
/
index.js
File metadata and controls
42 lines (38 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"use strict";
import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
var arr1;
var arr2;
[{
from: 'templates/index.html',
to: 'dist/output-index.html'
}, {
from: 'templates/layout.html',
to: 'dist/output-layout.html'
}].forEach(options => {
const html = readFileSync(options.from, 'utf8');
const plugins = [
function (tree) {
tree.messages.push({
type: 'dependency',
file: 'path/to/dependency.html',
from: tree.options.from
})
return tree;
}
]
const result = posthtml(plugins)
.use(function (tree) {
tree.messages.push({
type: 'dependency',
file: 'path/to/dependency.html',
from: 'use'
})
return tree;
})
.process(html, options)
.then(result => {
console.log(result.tree);
writeFileSync(options.to, result.html);
});
})