-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (50 loc) · 1.82 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
// CONFIG ----------------------------------------------------------------------
var SRC_JS = 'src/*.js';
var SRC_CSS = 'src/*.css';
// INIT ------------------------------------------------------------------------
var gulp = require('gulp');
var insert = require('gulp-insert');
var eslint = require('gulp-eslint');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var LICENSE = (function getLicense() {
var license = '';
var name = require('./bower.json').name;
var version = require('./VERSION.json').version;
var iso8601 = (new Date()).toISOString();
var description = require('./bower.json').description;
var homepage = require('./bower.json').homepage;
// Use comment style dual-compatible with JS and CSS
license += `/* ${name} v${version} (${iso8601})\n`;
license += (description) ? ` * ${description}\n` : '';
license += (homepage) ? ` * <${homepage}>\n` : '';
license += ' */\n';
license += '\n';
return license;
})();
// GULP ------------------------------------------------------------------------
gulp.task('default', () => {
gulp.start('lint', 'scripts', 'styles');
});
gulp.task('lint', () => {
return gulp.src(SRC_JS)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// Copy source contents first to "dist", prepend contents with license info,
// then create a minified version and rename.
gulp.task('scripts', () => {
return gulp.src(SRC_JS)
.pipe(insert.prepend(LICENSE))
.pipe(gulp.dest('dist'))
.pipe(uglify({ preserveComments: 'license' }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
// Prepend contents with license info and copy to "dist".
gulp.task('styles', () => {
return gulp.src(SRC_CSS)
.pipe(insert.prepend(LICENSE))
.pipe(gulp.dest('dist'));
});