-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
49 lines (43 loc) · 1.38 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
var gulp = require('gulp');
var ts = require('gulp-typescript');
var gutil = require('gulp-util');
var less = require('gulp-less');
var autoprefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var webserver = require('gulp-webserver');
gulp.task('scripts', function () {
var tsProject = ts.createProject('tsconfig.json');
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return tsResult.js
//.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('web/res/'));
});
gulp.task('css', function () {
return gulp.src('web/src/*.less')
.pipe(less({ style: 'compressed' }).on('error', gutil.log))
.pipe(autoprefix('last 3 version'))
.pipe(minifyCSS())
.pipe(gulp.dest('web/res/'));
});
gulp.task('watcher', function () {
gulp.watch('web/src/*.less', ['css']);
gulp.watch(['tsconfig.json', 'web/src/**/*.ts'], ['scripts']);
});
gulp.task('watch', ['css', 'scripts', 'watcher']);
gulp.task('server', ['css', 'scripts', 'watcher'], function() {
gulp.src('./web')
.pipe(webserver({
livereload: true,
directoryListing: {
enable:true,
path: 'web'
},
open: true,
}));
});
gulp.task('default', ['css', 'scripts']);