-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
87 lines (67 loc) · 1.96 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
'use strict';
let gulp = require('gulp');
let jspm = require('jspm');
let customConfig = require('./static/config.custom.js');
let sass = require('gulp-sass');
let watch = require('gulp-watch');
let rename = require('gulp-rename');
let path = require('path');
let contains = require('gulp-contains');
let fs = require('fs');
let runSequence = require('run-sequence');
let autoprefixer = require('gulp-autoprefixer');
let jshint = require('gulp-jshint');
let jscs = require('gulp-jscs');
let tslint = require('gulp-tslint');
let sassLint = require('gulp-sass-lint');
let tsSourceFiles = './jspmAssets/app/**/*.ts';
let jsSourceFiles = './jspmAssets/app/**/*.js';
gulp.task('jspm:install', () => {
jspm.setPackagePath('.');
return jspm.install(true, { lock: true });
});
gulp.task('jspm:unbundle', cb => {
jspm.setPackagePath('.');
jspm.unbundle()
.then(function () { cb(); })
.catch(cb);
});
gulp.task('jspm:prod', ['analyze', 'jspm:unbundle', 'jspm:install'], cb => {
jspm.setPackagePath('.');
let builder = new jspm.Builder();
builder.config(customConfig);
let bundleConfig = {
minify: true,
sourceMaps: false,
sourceMapContents: false,
injectConfig: true
};
builder.bundle(tsSourceFiles, './static/build/main.js', bundleConfig)
.then(() => {
cb();
})
.catch(cb);
});
gulp.task('analyze:js', () => {
return gulp.src(jsSourceFiles)
// Run JS Linter
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
// Run JS Checkstyle
.pipe(jscs())
.pipe(jscs.reporter());
});
gulp.task('analyze:ts', function () {
return gulp.src(tsSourceFiles)
// Run JS Linter
.pipe(tslint({
formatter: 'stylish'
}))
.pipe(tslint.report({
emitError: false
}));
});
gulp.task('analyze', ['analyze:js', 'analyze:ts']);
gulp.task('dev', ['jspm:unbundle']);
gulp.task('prod', ['jspm:prod']);
gulp.task('default', ['jspm:unbundle']);