-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (47 loc) · 1.4 KB
/
gulpfile.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 gulp = require( 'gulp' );
const gulpif = require( 'gulp-if' );
const uglify = require( 'gulp-uglify' );
const rename = require( 'gulp-rename' );
const rimraf = require( 'rimraf' );
const rollup = require( 'rollup' );
const runSequence = require( 'run-sequence' );
const sourcemaps = require( 'gulp-sourcemaps' );
const rollupBuble = require( 'rollup-plugin-buble' );
gulp.task( 'uglify', () => {
gulp.src( 'dist/tweenkey.js' )
.pipe( uglify( {
mangleProperties: {
regex: /_/
},
compress: true
} ) )
.pipe( rename('tweenkey.min.js') )
.pipe( gulp.dest( './dist' ) );
});
gulp.task( 'rollup', () => {
return rollup.rollup({
entry: './src/main.js',
plugins: [ rollupBuble() ]
}).then( ( bundle )=> {
bundle.write( {
dest: "./dist/tweenkey.js",
moduleName: 'Tweenkey',
format: 'umd'
} );
});
});
gulp.task( 'clean', ( cb ) => {
rimraf( './dist', cb );
});
gulp.task( 'build:prod', ( callback )=> {
runSequence( 'clean', 'rollup', 'uglify', callback );
});
gulp.task( 'build:dev', ( callback ) => {
runSequence( 'clean', 'rollup', callback );
});
gulp.task( 'watch', ()=> {
let watcher = gulp.watch( [ 'src/**/*.js', 'demo/*' ], [ 'build:dev' ] );
watcher.on( 'change', ( event )=> {
console.log( `\n[${event.type}]: ${event.path}` );
})
});