-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgulpfile.ts
72 lines (63 loc) · 2.26 KB
/
gulpfile.ts
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
"use strict";
const gulp = require('gulp');
const del = require('del');
const ts = require('gulp-typescript');
const newer = require('gulp-newer');
const autoprefixer = require('gulp-autoprefixer');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const htmlmin = require('gulp-htmlmin');
const uglify = require('gulp-uglify');
const staticDir = 'src/main/resources/static/';
const webAppDir = 'src/main/javascript/';
const lib = [
'core-js/client/shim.min.js',
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'reflect-metadata/Reflect.js',
'rxjs/**/*.js',
'zone.js/dist/**',
'@angular/**/bundles/**'
];
gulp.task('library', () => {
return gulp.src(lib, {cwd: "node_modules/**"})
.pipe(newer(staticDir + 'lib/'))
.pipe(gulp.dest(staticDir + 'lib/'))
});
gulp.task('typescript-compile', () => {
let tsProject = ts.createProject('tsconfig.json');
return gulp.src(['typings/index.d.ts', webAppDir + '**/*.ts'])
.pipe(newer({dest: staticDir, ext: '.js'}))
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(uglify())
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest(staticDir))
});
gulp.task('html-replace', () => {
return gulp.src(webAppDir + '**/*.html')
.pipe(newer(staticDir))
.pipe(sourcemaps.init())
.pipe(htmlmin({collapseWhitespace: true, caseSensitive: true}))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest(staticDir))
});
gulp.task('css-replace', () => {
return gulp.src(webAppDir + '**/*.scss')
.pipe(newer({dest: staticDir, ext: '.css'}))
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest(staticDir))
});
gulp.task('build', ['typescript-compile', 'library', 'html-replace', 'css-replace']);
gulp.task('default', ['typescript-compile', 'html-replace', 'css-replace']);
gulp.task('watch', function() {
gulp.watch(webAppDir + '**/*.ts', ['typescript-compile']);
gulp.watch(webAppDir + '**/*.html', ['html-replace']);
gulp.watch(webAppDir + '**/*.scss', ['css-replace']);
});