-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
106 lines (90 loc) · 2.61 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
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
106
'use strict';
import gulp from 'gulp';
import plugins from 'gulp-load-plugins';
const $$ = plugins();
// import buffer from 'vinyl-buffer';
import del from 'del';
// import source from 'vinyl-source-stream';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import yargs from 'yargs';
const argv = yargs
.alias('p', 'production')
.argv;
import cfg from './build.config';
import wpCfg from './webpack.config.babel';
const IS_DEVELOPMENT = argv.p || process.env.NODE_ENV === 'development';
gulp.task('default', ['watch']);
gulp.task('watch', () => {
var config = Object.create(wpCfg);
config.debug = true;
config.entry.index.unshift('webpack-dev-server/client?http://localhost:8080/');
// Start a webpack-dev-server
new WebpackDevServer(webpack(config), {
stats: {
colors: true
}
}).listen(8080, 'localhost', function(err) {
if(err) throw new $$.util.PluginError('webpack-dev-server', err);
$$.util.log('[webpack-dev-server]', 'http://localhost:8080/');
});
});
gulp.task('build', (cb) => {
webpack(wpCfg, (err, stats) => {
if(err) throw new $$.util.PluginError('webpack', err);
$$.util.log('[webpack]', stats.toString({
colors: true,
progress: true
}));
cb();
});
});
gulp.task('clean', () => {
// TODO move path to config
return del('./dist');
});
gulp.task('lint', ['lint:code', 'lint:style', 'lint:template']);
gulp.task('code:lint', ['lint:code']);
gulp.task('lint:code', () => {
return gulp.src(cfg.code.src, {base: './'})
.pipe($$.plumber({
errorHandler: $$.notify.onError(err => ({
title: 'Code Lint',
message: err.message
}))
}))
.pipe($$.cached('lint:code'))
.pipe($$.jscs({
configPath: cfg.ext.jscs,
fix: true
}))
.pipe($$.jshint(cfg.ext.jshint))
.pipe($$.jshint.reporter('jshint-stylish'))
.pipe($$.jshint.reporter('fail'));
});
gulp.task('style:lint', ['lint:style']);
gulp.task('lint:style', function() {
return gulp.src(cfg.style.src)
.pipe($$.plumber({
errorHandler: $$.notify.onError(err => ({
title: 'Style Lint',
message: err.message
}))
}))
.pipe($$.cached('lint:style'))
.pipe($$.sassLint())
.pipe($$.sassLint.format())
.pipe($$.sassLint.failOnError());
});
gulp.task('template:lint', ['lint:template']);
gulp.task('lint:template', function() {
return gulp.src([cfg.template.src, cfg.template.main])
.pipe($$.plumber({
errorHandler: $$.notify.onError(err => ({
title: 'Template Lint',
message: err.message
}))
}))
.pipe($$.cached('lint:template'))
.pipe($$.html5Lint());
});