forked from shlomiassaf/ngx-modialog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.js
More file actions
79 lines (67 loc) · 2.04 KB
/
make.js
File metadata and controls
79 lines (67 loc) · 2.04 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
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
#!/usr/bin/env node
/*eslint no-console: 0, no-sync: 0*/
'use strict';
const fs = require('fs');
const del = require('del');
const path = require('path');
const async = require('async');
const Builder = require('systemjs-builder');
const pkg = require('./package.json');
const name = pkg.name;
const TARGET_DIR = path.resolve('./dist/systemjs');
async.waterfall([
//clearTarget,
getSystemJsBundleConfig,
buildSystemJs({mangle: false}),
getSystemJsBundleConfig,
buildSystemJs({minify: true, sourceMaps: true, mangle: false})
], function (err) {
if (err) {
throw err;
}
});
function clearTarget(cb) {
return del(TARGET_DIR, {force: true})
.then( paths => console.log(`Deleted files and folders:\n${paths.join('\n')}`) )
.then( _ => cb())
.catch( err => cb(err));
}
function getSystemJsBundleConfig(cb) {
try {
let config = {
baseURL: './dist/commonjs',
transpiler: 'typescript',
typescriptOptions: {
module: 'cjs'
},
map: {
typescript: 'node_modules/typescript/lib/typescript.js',
'@angular': 'node_modules/@angular',
rxjs: 'node_modules/rxjs'
},
paths: {
'*': '*.js'
},
meta: {
'node_modules/@angular/*': { build: false },
'node_modules/rxjs/*': { build: false }
},
};
cb(null, config);
}
catch (ex) {
cb(ex);
}
}
function buildSystemJs(options) {
return function (config, cb) {
let fileName = `${name}-${pkg.version}` + (options && options.minify ? '.min' : '') + '.js';
let dest = path.resolve(__dirname, TARGET_DIR, fileName);
console.log('Bundling system.js file:', fileName, options);
let builder = new Builder();
builder.config(config);
return builder
.bundle([name].join('/'), dest, options)
.then(()=>cb()).catch(cb);
};
}