forked from realitymod/PRGallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (67 loc) · 1.85 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
const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const tsify = require("tsify");
const htmlmin = require("gulp-htmlmin");
const debug = require("gulp-debug");
const server = require("gulp-live-server");
const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");
const concat = require("gulp-concat");
const cleanCSS = require('gulp-clean-css');
const uglify = require('gulp-uglify-es').default;
const rename = require("gulp-rename");
gulp.task('browserify', function() {
return browserify('app/index.ts')
.plugin(tsify)
.bundle()
.pipe(source('main.js'))
.pipe(gulp.dest('dist'));
});
gulp.task("uglify", ["browserify"], function () {
return gulp.src("dist/main.js")
.pipe(rename("main.min.js"))
.pipe(uglify(/* options */))
.pipe(gulp.dest("dist/"));
});
/*
* Minify and uglify CSS
*/
gulp.task('styles', function() {
return gulp.src([
'app/**/*.scss',
])
.pipe(debug())
.pipe(sass())
.pipe(autoprefixer())
.pipe(concat("bundle.css"))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist'));
});
/*
* Minify HTML
*/
gulp.task('minify', function() {
return gulp.src('app/**/*.html')
.pipe(debug())
.pipe(htmlmin({collapseWhitespace: true, removeComments:true}))
.pipe(gulp.dest('dist'));
});
/*
*
*/
gulp.task('watch', function() {
gulp.watch('app/**/*.html', ['minify']);
gulp.watch('app/**/*.ts', ['uglify']);
gulp.watch('app/**/*.scss', ['styles']);
});
/*
* Run Server
*/
gulp.task('webserver', ['uglify', 'minify', 'styles'], function() {
server
.static('dist', 3000)
.start();
});
gulp.task('default', ['webserver', 'watch']);