-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
101 lines (63 loc) · 2.06 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
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')({pattern: ['*'],
rename: {'jshint': 'jshintG'}});
const config = require('./gulp-config.js');
gulp.task('plugins', function() {
console.log(plugins);
});
gulp.task('clear', clear);
gulp.task('html', html);
gulp.task('less', less);
gulp.task('js', js);
gulp.task('build', ['clear', 'html', 'less', 'js']);
gulp.task('browserSync', ['build'], browserSync);
gulp.task('default', ['build', 'browserSync'], function() {
gulp.watch(config.paths.src.html, ['html']);
gulp.watch(config.paths.src.less, ['less']);
gulp.watch(config.paths.src.js, ['js']);
});
// Gulp Functions
function browserSync() {
plugins.browserSync.init(config.browserSync);
}
function clear() {
plugins.del(config.paths.dest.root);
plugins.del(config.paths.test.root);
}
function html() {
return gulp.src(config.paths.src.html)
.pipe(gulp.dest(config.paths.test.root))
.pipe(plugins.browserSync.stream());
}
function js() {
gulp.src(config.paths.src.js)
.pipe(plugins.jshint({
esversion: 6
}))
.pipe(plugins.jshint.reporter('jshint-stylish'));
return gulp.src(config.paths.src.jsMain)
.pipe(plugins.webpackStream(config.webpack, plugins.webpack))
.on('error', function() {
this.emit('end');
})
.pipe(gulp.dest(config.paths.dest.root))
.pipe(gulp.dest(config.paths.test.js))
.pipe(plugins.browserSync.stream());
}
function less() {
return gulp.src(config.paths.src.less)
.pipe(plugins.plumber(function(error) {
plugins.util.log(plugins.util.colors.red('--------------------------------------------------\n\n'))
plugins.util.log(plugins.util.colors.red('Error (' + error.plugin + '):\n' + error.message + '\n\n'));
plugins.util.log(plugins.util.colors.red('--------------------------------------------------\n'))
}))
.pipe(plugins.concat('styles.css'))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.less())
.on('error', function() {
this.emit('end');
})
.pipe(plugins.sourcemaps.write())
.pipe(gulp.dest(config.paths.test.css))
.pipe(plugins.browserSync.stream());
}