forked from fingerpich/jalali-angular-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
55 lines (45 loc) · 1.11 KB
/
build.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
const fs = require('fs');
const path = require('path');
const ncp = require('ncp');
const rimraf = require('rimraf');
const less = require('less');
const ng2Inline = require('./build-helpers/inliner');
const inline = (dir) => {
let files = fs.readdirSync(dir);
files.forEach((file) => {
const src = path.join(dir, file);
if (fs.statSync(src).isDirectory()) {
inline(src);
}
else if (src.endsWith('.component.ts')) {
ng2Inline(fs.readFileSync(src, 'utf-8'), {
base: dir
}, dir).then((file) => {
fs.writeFileSync(src, file);
});
}
});
};
console.log('cleaning...');
rimraf.sync('prebuild', fs, (err) => {
if (err) {
return console.error(err);
}
});
rimraf.sync('aot', fs, (err) => {
if (err) {
return console.error(err);
}
});
console.log('done cleaning!');
console.log('cloning src...');
ncp('src', 'prebuild', (err) => {
if (err) {
return console.error(err);
}
console.log('done cloning src!');
console.log('inlining...');
inline(path.resolve('./prebuild/'));
console.log('done inlining!');
console.log('ready for ngc!');
});