-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 872 Bytes
/
index.js
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
"use strict"
import * as postcss from "postcss"
import Stringifier from "postcss/lib/stringifier"
import fs from "fs"
export default stringify
class DomModule extends Stringifier {
root(node, options = {}) {
let template, webcomponentHeader, webcomponentFooter
try {
template = fs.readFileSync(`${__dirname}/template.html`, "utf8")
webcomponentHeader = template.match(/^(.|\n)+<style>/)[0]
webcomponentFooter = template.match(/<\/style>(.|\n)+$/)[0]
} catch(error) {
console.error(error)
}
this.builder(webcomponentHeader.replace(/{{id}}/, options.id))
super.root(node)
this.builder(webcomponentFooter)
}
}
function stringify(node, builder) {
const domModule = new DomModule(builder)
domModule.root(node, { id: "test1" })
}