-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (38 loc) · 1.25 KB
/
index.js
File metadata and controls
46 lines (38 loc) · 1.25 KB
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
try {
require('module-alias/register');
} catch {
// do nothing
}
const fs = require('fs');
const path = require('path');
const isPotentialCustomElementName = require('is-potential-custom-element-name');
const { getArgv, getRootDir, logErrorMessage } = require('@ixon-cdk/core');
function main() {
const argv = getArgv();
const buildTarget = argv._[0];
const tag = argv._[1];
const { input } = argv;
const output = argv.output || 'dist/bundle/main.min.js';
const assets = JSON.parse(argv.assets || '[]');
const watch = !!argv.watch;
if (!input) {
logErrorMessage(
'Must supply an input file, relative to the workspace root.',
);
process.exit();
}
if (!fs.existsSync(path.join(getRootDir(), input))) {
logErrorMessage(`Input file '${input}' does not exist.`);
process.exit();
}
if (!isPotentialCustomElementName(tag)) {
logErrorMessage(
`Custom element name '${tag}' is invalid. See https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname`,
);
process.exit();
}
if (buildTarget === 'browser') {
require('./browser')(input, output, tag, assets, true, watch);
}
}
main();