forked from ivanblazevic/ngx-unused-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
58 lines (49 loc) · 1.06 KB
/
index.ts
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
#!/usr/bin/env node
/*
Find unused css inside Angular components
*/
//import Main from "./src/main";
import { Config } from "./src/config";
const path = require("path");
const fs = require("fs");
const meow = require("meow");
const defaultConfigPath = ".ngx-unused-css.json";
const cli = meow(
`
Usage
$ ngx-unused-css
Options
--config, -c override default config path
Examples
$ ngx-unused-css --config ngx-custom-unused-css.json
`,
{
flags: {
config: {
type: "string",
alias: "c"
}
}
}
);
let config: Config = {
path: "src/app",
ignore: []
};
if (cli.flags.config) {
config = require(__dirname + "/." + cli.flags.config);
} else if (fs.existsSync(path.resolve(defaultConfigPath))) {
config = require(path.resolve(defaultConfigPath));
}
export const conf = config;
export function getConfig() {
return config;
}
// Use dynamic import so config is initialized on every import
async function start() {
const mainPromise = import("./src/main");
mainPromise.then(res => {
new res.default();
});
}
start();