-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
76 lines (69 loc) · 1.74 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import uglify from 'uglify-js';
import {rollup} from 'rollup';
import babel from 'rollup-plugin-babel';
import fs from 'fs';
const innerMethods = [
'startedActions',
'startedUntrackedActions',
'afterActionsEndedCallbacks',
'values',
'callbacks',
'shallowCallbacks',
'subscriptions',
'propsScopes',
'_setValue',
'_makeTrackable',
'setValueSilently',
'initValue',
'deleteValue',
'stopListen',
'getValue',
'onChange',
'onShallowChange',
'_addCallback',
'reportChange',
'setPropScope',
'isWaitingForActionsToEnd',
'setWaitingForActionsToEnd',
'isRerenderCallbackSetted',
'setRerenderCallback',
'stopRerender',
'setMounted',
'waitingForActionsToEnd',
'rerenderCallbackSubscription',
'isMounted'
];
gulp.task('default', ['build', 'copy']);
gulp.task('rollup', () => {
return rollup({
entry: 'src/index.js',
plugins: [
babel({
babelrc: false,
"presets":[
[ "es2015", { "modules": false } ]
],
"plugins": ["external-helpers"]
})
]
}).then(bundle => bundle.write({
format: 'cjs',
dest: 'build/lib/index.js'
}));
});
gulp.task('build', ['rollup'], () => {
const result = uglify.minify('build/lib/index.js', {
mangle: {
toplevel: true
},
mangleProperties: {
regex: new RegExp(`^(${innerMethods.join('|')})$`)
}
});
fs.writeFile('build/lib/index.min.js', result.code);
});
gulp.task('copy', () => {
gulp.src(['src/index.d.ts', 'package.json', 'LICENSE', 'README.md'])
.pipe(gulp.dest('build/lib'));
});