-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
42 lines (38 loc) · 1.1 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
const babel = require("gulp-babel");
const gulp = require('gulp');
const rename = require("gulp-rename");
const rollup = require('rollup-stream');
const sourcemaps = require('gulp-sourcemaps');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const uglify = require('gulp-uglify');
const eslint = require('gulp-eslint');
gulp.task('lint', () => {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('build-js', function () {
rollup({
entry: './src/SVGMountainRange.js',
sourceMap: true,
format: 'iife',
moduleName: 'SVGMountainRange'
})
.on('error', e => {
console.error(`${e.stack}`);
})
.pipe(source('SVGMountainRange.js', './src'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(babel({presets: ['es2015']}))
.pipe(rename('svg-mountain-range.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'));
});
gulp.task('watch-js', function(){
gulp.watch('src/**/*.js', ['build-js']);
});
gulp.task('default', ['build-js', 'watch-js']);