-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
90 lines (73 loc) · 2.46 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
(function() {
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var tslint = require('gulp-tslint');
var appDev = './src/main/webapp/';
var appProd = './src/main/webapp/dist/';
/* Mixed */
var ext_replace = require('gulp-ext-replace');
/* CSS */
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('autoprefixer');
var precss = require('precss');
var cssnano = require('cssnano');
/* JS & TS */
var typescript = require('gulp-typescript');
/* Images */
var imagemin = require('gulp-imagemin');
var tsProject = typescript.createProject('src/main/webapp/ts/tsconfig.json');
gulp.task('build-css', function() {
return gulp.src(appDev + 'scss/*.scss')
.pipe(sourcemaps.init())
.pipe(postcss([precss, autoprefixer, cssnano]))
.pipe(sourcemaps.write('.'))
.pipe(ext_replace('.css'))
.pipe(gulp.dest(appProd + 'css/'))
.pipe($.size({'title': 'css'}));
});
gulp.task('build-ts', function() {
var result = gulp.src([appDev + 'ts/**/*.ts'])
.pipe(tslint())
.pipe(tslint.report("verbose"))
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));
// pipe the js files to dist folder
result.dts.pipe(gulp.dest(appProd + 'js'));
return result.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(appProd + 'js'))
.pipe($.size({'title': 'ts'}));
});
gulp.task('build', [
'build-ts', 'build-css', 'build-img', 'build-fonts', 'build-locale'
], function() {
return gulp.src(appDev + 'index.html')
.pipe($.useref({'searchPath': './'}))
.pipe(gulp.dest(appProd))
.pipe($.size({'title': 'html'}));
});
gulp.task('build-img', function() {
return gulp.src(appDev + 'img/**/*')
.pipe(imagemin({progressive: true}))
.pipe(gulp.dest(appProd + 'img/'));
});
gulp.task('build-fonts', function() {
return gulp.src(appDev + 'fonts/**/*')
.pipe(gulp.dest(appProd + 'fonts/'));
});
gulp.task('build-locale', function() {
return gulp.src(appDev + 'locale/**/*')
.pipe(gulp.dest(appProd + 'locale/'));
});
gulp.task('clean', function() {
return gulp.src(appProd, {read: false})
.pipe($.clean());
});
gulp.task('watch', function() {
gulp.watch(appDev + '**/*.ts', ['build-ts']);
gulp.watch(appDev + 'scss/**/*.scss', ['build-css']);
gulp.watch(appDev + 'img/*', ['build-img']);
});
gulp.task('default', ['build-html']);
}())