-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (62 loc) · 2.06 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
const gulp = require("gulp");
const sass = require("gulp-sass");
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const rename = require("gulp-rename");
const b = require("browser-sync").create();
const typescript = require('gulp-typescript');
const tsc = typescript.createProject('tsconfig.json');
/*
============================================================================================================
tasks - main
============================================================================================================
*/
gulp.task("dev", ["watch"]);
gulp.task("build", ["sass", "ts", "minify"]);
gulp.task("default", ["dev"]);
/*
============================================================================================================
tasks - subs
============================================================================================================
*/
gulp.task('ts', function () {
const prj = tsc.src()
.pipe(tsc())
.on('error', e => console.error(e));
return prj.js.pipe(gulp.dest('.'));
});
gulp.task("sass", function () {
return gulp.src("./src/*.scss")
.pipe(sass({ outputStyle: 'compressed' }))
.on('error', e => console.error(e))
.pipe(rename("tuna-jsdatepicker.css"))
.pipe(gulp.dest("./dist"));
});
gulp.task("minify", function () {
return gulp.src([
'./node_modules/tuna-jstemplate/dist/tuna-jstemplate.js',
'./dist/tuna-jsdatepicker.js'
])
.pipe(concat('tuna-jsdatepicker.bundled.js'))
.pipe(gulp.dest('./dist'))
.pipe(rename('tuna-jsdatepicker.bundled.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task("watch", ["ts", "sass", "browsersync"], function () {
gulp.watch("./src/**/*.ts", ["ts"]);
gulp.watch("./src/**/*.scss", ["sass"]);
gulp.watch("./dist/**/*.*").on('change', b.reload);
gulp.watch("./demo/**/*.html").on('change', b.reload);
});
gulp.task("browsersync", function () {
b.init({
server: {
baseDir: ["./demo"],
routes: {
"/dist": "dist",
"/node_modules": "node_modules"
}
},
})
});