-
Notifications
You must be signed in to change notification settings - Fork 486
/
Gulpfile.js
60 lines (53 loc) · 1.78 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
56
57
58
59
60
const gulp = require("gulp");
const sourcemaps = require("gulp-sourcemaps");
const babel = require("gulp-babel");
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const header = require('gulp-header');
const gutil = require('gulp-util');
const rollup = require('gulp-rollup');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const pkg = require('./package.json');
const banner = [
'/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @author <%= pkg.author %>',
' * @license <%= pkg.license %>',
'**/',
'',
].join('\n');
gulp.task("babel", function(){
return gulp.src("src/*.js")
.pipe(babel())
.pipe(gulp.dest("dist"));
});
gulp.task('bundle', ['babel'], function(){
return gulp.src(["dist/sticky-sidebar.js", "dist/jquery.sticky-sidebar.js"])
.pipe(sourcemaps.init())
// transform the files here.
.pipe(rollup({
allowRealFiles: true,
// any option supported by Rollup can be set here.
input: ['./dist/sticky-sidebar.js', './dist/jquery.sticky-sidebar.js'],
format: 'umd',
name: 'StickySidebar',
plugins: [ resolve(), commonjs() ]
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'));
});
gulp.task('uglify', ['bundle'], function(){
return gulp.src(["dist/sticky-sidebar.js", "dist/jquery.sticky-sidebar.js"])
.pipe(uglify())
.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
.pipe(header(banner, {pkg}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("dist/"));
});
gulp.task('watch', function() {
gulp.watch('src/*.js', ['default']);
});
gulp.task('default', ['babel', 'bundle', 'uglify']);