-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminify.mjs
40 lines (34 loc) · 1.04 KB
/
minify.mjs
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
import * as fs from 'fs';
import {minify} from 'minify';
(async () => {
const components = ['gui', 'joystick', 'telemetry'];
for (const component of components) {
const name = component.toUpperCase();
const htmlFile = await minifyHTML(`./src/${component}.html`);
const cssFile = await minifyCSS(`./src/${component}.css`);
fs.writeFileSync(`./src/${component}-template.ts`, `// Generated with 'minify'.
export const ${name}Styles: string = \`${cssFile}\`;
export const ${name}Template: string = \`${htmlFile}\`;
`);
}
})();
function minifyHTML(path) {
return minify(path, {
html: {
includeAutoGeneratedTags: true,
collapseWhitespace: true,
removeComments: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeTagWhitespace: true,
useShortDoctype: true
}
});
}
function minifyCSS(path) {
return minify(path, {
css: {
}
});
}