This repository has been archived by the owner on Jun 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (60 loc) · 1.54 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
61
62
63
64
65
66
67
'use strict';
// Globals
const gulp = require('gulp');
const rollupBuble = require('rollup-plugin-buble');
const rollupCommonjs = require("rollup-plugin-commonjs");
const betterRollup = require('gulp-better-rollup');
const jshint = require('gulp-jshint');
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const size = require('gulp-size');
const stripComments = require('gulp-strip-comments');
const uglify = require('gulp-uglify');
const projectName = "slightly";
// Tasks
gulp.task('lint', function () {
return gulp.src(['src/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build', function () {
return gulp.src('./src/wrapper.js')
.pipe(plumber())
.pipe(betterRollup({
plugins: [
rollupBuble({
transforms: {
dangerousForOf: true
}
}),
rollupCommonjs()
]
}, {
moduleName: 'Slightly',
format: 'umd',
}))
.pipe(stripComments())
.pipe(rename(projectName + '.js'))
.pipe(size({
showFiles: true
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('minify', ['lint', 'build'], function () {
return gulp.src(['./dist/' + projectName + '.js'])
.pipe(plumber())
.pipe(uglify())
.pipe(rename(projectName + '.min.js'))
.pipe(size({
showFiles: true
}))
.pipe(size({
gzip: true,
showFiles: true
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch', function () {
gulp.watch(['src/**/*.js'], ['minify']);
});
gulp.task('default', ['minify']);