-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
105 lines (92 loc) · 2.39 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'use strict';
var gulp = require('gulp'),
hint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
rename = require('gulp-rename'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
concat = require('gulp-concat'),
debug = require('gulp-debug'),
sourcemaps = require('gulp-sourcemaps');
var DEV_ROOT = 'build/dev',
DIST_ROOT = 'build/dist',
DIST_NAME = 'dataimport';
var src = {
vendorCSS: 'vendor_modules/**/*.css',
vendorJS: [
'vendor_modules/jquery.min.js',
'vendor_modules/handsontable.full.js',
'vendor_modules/papaparse.js',
'vendor_modules/fuse.js',
],
js: [
'src/scripts/sheet.js',
'src/scripts/dataimport.js',
'src/scripts/validators.js',
],
devJS: [
'src/scripts/dropfile.js',
'src/scripts/main.js'
],
css: ['src/css/dataimport.css'],
devCSS: ['src/css/main.css'],
html: 'src/*.html',
};
gulp.task('hint', function () {
return gulp.src(src.js).pipe(hint('.jshintrc'))
.pipe(hint.reporter(stylish))
.pipe(hint.reporter('fail'));
});
gulp.task('vendor:dev', function () {
return gulp.src(src.vendorJS)
.pipe(concat('vendor.js'))
.pipe(gulp.dest(DEV_ROOT));
});
gulp.task('scripts:dev', ['hint', 'vendor:dev'], function () {
return gulp.src(src.js.concat(src.devJS))
.pipe(debug())
.pipe(sourcemaps.init())
.pipe(concat('all.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(DEV_ROOT))
.pipe(reload({
stream: true
}));
});
gulp.task('scripts:dist', ['hint'], function () {
return gulp.src(src.js)
.pipe(concat(DIST_NAME + '.js'))
.pipe(gulp.dest(DIST_ROOT));
});
gulp.task('styles:dev', function () {
return gulp.src(src.vendorCSS.concat(src.css))
.pipe(concat('all.css'))
.pipe(gulp.dest(DEV_ROOT))
.pipe(reload({
stream: true
}));
});
gulp.task('styles:dist', function () {
return gulp.src(src.css)
.pipe(concat(DIST_NAME + '.css'))
.pipe(gulp.dest(DIST_ROOT));
});
gulp.task('html:dev', function () {
return gulp.src('src/dev.html')
.pipe(rename('index.html'))
.pipe(gulp.dest(DEV_ROOT))
.pipe(reload({
stream: true
}));
});
gulp.task('serve', function () {
browserSync({
server: DEV_ROOT
});
gulp.watch(src.js.concat(src.devJS), ['scripts:dev']);
gulp.watch(src.css, ['styles:dev']);
gulp.watch(src.html, ['html:dev']);
});
gulp.task('build', [
'scripts:dist', 'styles:dist'
]);