-
Notifications
You must be signed in to change notification settings - Fork 8
/
prepare_web-components.js
59 lines (52 loc) · 1.34 KB
/
prepare_web-components.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const fs = require('fs-extra');
const concat = require('concat');
const build = async () => {
const files = [
'tmp/web-components/main.js',
'tmp/web-components/polyfills.js',
'tmp/web-components/runtime.js',
];
await fs.ensureDir('dist/libs/web-components');
await concat(files, 'dist/libs/web-components/web-components.js');
await fs.copyFile(
'apps/web-components/package.json',
'dist/libs/web-components/package.json'
);
await fs.copyFile(
'tmp/web-components/3rdpartylicenses.txt',
'dist/libs/web-components/3rdpartylicenses.txt'
);
await fs.copyFile(
'apps/web-components/README.md',
'dist/libs/web-components/README.md'
);
await fs.copyFile(
'apps/web-components/LICENSE.txt',
'dist/libs/web-components/LICENSE.txt'
);
const license = await fs.readFile(
'dist/libs/web-components/LICENSE.txt',
'utf-8'
);
const thirdPartyLicenses = await fs.readFile(
'tmp/web-components/3rdpartylicenses.txt',
'utf-8'
);
let jsCode = await fs.readFile(
'dist/libs/web-components/web-components.js',
'utf-8'
);
jsCode = `/*
${license}
*/
${jsCode}
/* Third party licenses:
${thirdPartyLicenses}
*/
`;
await fs.writeFile('dist/libs/web-components/web-components.js', jsCode, {
encoding: 'utf-8',
});
console.log('Web-Components Build OK');
};
build();