This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.js
86 lines (64 loc) · 2.35 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//get type helper
var Transpile = require('fuse-box-typechecker').TypeHelper
const { task, src } = require('fuse-box/sparky');
const packageName = require('./package.json').name;
// configure
var transpileTo = function (outDir, moduleType) {
var transpile = Transpile({
tsConfig: './tsconfig.json',
basePath: './',
tsLint: './tslint.json',
name: `building:${moduleType}, at: ${outDir}`,
shortenFilenames: true,
yellowOnLint: true,
emit: true,
clearOnEmit: true
});
transpile.options.tsConfigJsonContent.compilerOptions.rootDir = `src/${packageName}`;
transpile.options.tsConfigJsonContent.compilerOptions.outDir = outDir;
transpile.options.tsConfigJsonContent.compilerOptions.module = moduleType;
transpile.options.tsConfigJsonContent.paths = {};
transpile.options.tsConfigJsonContent.exclude = ['node_modules', 'dist', 'src/sample', 'dev', 'distTS'];
return transpile.runSync();
}
var errors = transpileTo('dist/commonjs/', 'commonjs');
// if commonjs had no errors then we do amd/system and copy css/html
if (!errors) {
// transpile too
transpileTo('dist/amd/', 'amd');
transpileTo('dist/system/', 'system');
transpileTo('dist/es2015/', 'es2015');
task('default', () => {
// ------------------------------------------
// ts code
// ------------------------------------------
src('**/*.*', { base: `src/${packageName}` })
.clean('distTS/')
.dest('distTS/')
.exec();
// ------------------------------------------
// css
// ------------------------------------------
// clean
src('./dist/**/*.*').clean('*.css')
//copy
src('**/*.css', { base: `src/${packageName}` })
.dest('dist/commonjs/')
.dest('dist/amd/')
.dest('dist/system/')
.dest('dist/es2015/')
.exec();
// ------------------------------------------
// html
// ------------------------------------------
// clean
src('./dist/**/*.*').clean('*.html')
// copy
src('**/*.html', { base: `src/${packageName}` })
.dest('dist/commonjs/')
.dest('dist/amd/')
.dest('dist/system/')
.dest('dist/es2015/')
.exec();
});
}