-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
23 lines (20 loc) · 881 Bytes
/
Copy pathbuild.js
File metadata and controls
23 lines (20 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const dir = __dirname;
const html = fs.readFileSync(path.join(dir, 'index.html'), 'utf8');
const css = fs.readFileSync(path.join(dir, 'style.css'), 'utf8');
const configJs = fs.readFileSync(path.join(dir, 'config.js'), 'utf8');
const topicJs = fs.readFileSync(path.join(dir, 'topic.js'), 'utf8');
const appJs = fs.readFileSync(path.join(dir, 'app.js'), 'utf8');
let output = html;
output = output.replace(
'<link rel="stylesheet" href="style.css" />',
`<style>\n${css}\n</style>`
);
output = output.replace(
' <script src="config.js"></script>\n <script src="topic.js"></script>\n <script src="app.js"></script>',
`<script>\n${configJs}\n${topicJs}\n${appJs}\n</script>`
);
fs.writeFileSync(path.join(dir, 'dist.html'), output, 'utf8');
console.log('Built dist.html successfully.');