-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
68 lines (59 loc) · 1.59 KB
/
gulpfile.babel.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
'use strict';
import 'jshint-stylish';
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import sourcemaps from 'gulp-sourcemaps';
import jshint from 'gulp-jshint';
import header from 'gulp-header';
import browserify from 'browserify';
import webserver from 'gulp-webserver';
import rename from 'gulp-rename';
import pkg from './package.json';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import babelify from 'babelify';
const IW = {};
IW.banner = [
'/**',
' ** <%= pkg.name %> - <%= pkg.description %>',
' ** @author <%= pkg.author %>',
' ** @version v<%= pkg.version %>',
' **/',
''
].join('\n');
IW._paths = {
main: './src/index.js',
js: './src/**/*.js',
demo: './demo',
demoJS: './demo/js'
};
IW.minifiedName = 'ironwing.min.js';
gulp.task('scripts', ['lint'], () => {
var b = browserify({
entries: IW._paths.main,
debug: true
}).transform(babelify);
return b.bundle()
.pipe(source('app.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true, debug: true}))
// .pipe(uglify())
.pipe(header(IW.banner, { pkg: pkg }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(IW._paths.demoJS));
});
gulp.task('lint', () => {
return gulp.src(IW._paths.js)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('webserver', () => {
gulp.src(IW._paths.demo)
.pipe(webserver({
open: true
}));
});
gulp.task('default', ['webserver'], () => {
gulp.watch(IW._paths.js, ['scripts']);
});