-
Notifications
You must be signed in to change notification settings - Fork 29
/
rollit.js
101 lines (91 loc) · 2.27 KB
/
rollit.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"use strict";
//import babel from 'rollup-plugin-babel';
//const babel = require('rollup-plugin-babel');
const buble = require('rollup-plugin-buble');
const rollup = require('rollup');
const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const writeFile = require('fs').writeFile;
const UglifyJS = require('uglify-js');
const pack = require('./package.json');
const external = Object.keys(pack.dependencies || {});
rollup.rollup({
entry: 'src/index.js',
plugins: [
nodeResolve({
jsnext: true,
main: true,
module: true
}),
commonjs(),
buble()
],
external: external
}).then((bundle)=>{
bundle.write({
dest: 'dist/bundle.js',
format: 'cjs',
moduleName: 'dom-autoscroller',
sourceMap: true
});
bundle.write({
dest: 'dist/bundle.es.js',
format: 'es',
sourceMap: true
});
}).catch(onErrorCB('bundle'));
rollup.rollup({
entry: 'src/index.js',
plugins: [
nodeResolve({
jsnext: true,
main: true
}),
commonjs(),
buble()
],
}).then((bundle)=>{
let b = bundle.write({
dest: 'dist/dom-autoscroller.js',
format: 'iife',
sourceMap: true,
moduleName: 'autoScroll'
});
b.then(what=>{
try{
var result = UglifyJS.minify('dist/dom-autoscroller.js');
//console.log('result ',result)
writeFile('dist/dom-autoscroller.min.js', result.code, onErrorCB('minify'));
}catch(e){
console.log('minify error ', e)
}
})
}).catch(onErrorCB('script sources'));
rollup.rollup({
entry: 'test/src.js',
plugins: [
nodeResolve({
main: true
}),
commonjs(),
buble()
]
}).then(bundle=>{
//console.log('what')
bundle.write({
dest: 'test/code.js',
format: 'iife',
sourceMap: true,
moduleName: 'autoScroll'
});
}).catch(onErrorCB('test code'));
function onErrorCB(message){
return function(e){
if(e){
if(message)
console.log(message);
console.log(e);
console.log(e.stack);
}
};
}