This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (94 loc) · 2.21 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'use script';
var gulp = require('gulp');
var webserver = require('gulp-webserver');
var fs = require('fs');
var minimist = require('minimist');
var xmllint = require('xmllint');
var chalk = require('chalk');
var $ = require('gulp-load-plugins')({ lazy: true });
var del = require('del');
var runSequence = require('run-sequence');
var Xml2Js = require('xml2js');
var config = {
release: './dist'
};
gulp.task('help', $.taskListing.withFilters(function (task) {
var mainTasks = ['default', 'help', 'serve-static'];
var isSubTask = mainTasks.indexOf(task) < 0;
return isSubTask;
}));
gulp.task('default', ['help']);
/** +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ **/
/**
* Startup static webserver.
*/
gulp.task('serve', function () {
gulp.src(['app'])
.pipe(webserver({
https: true,
port: '8443',
host: 'localhost',
livereload: true,
open: true,
directoryListing: false,
fallback: 'index.html'
}));
});
/**
* Removes existing dist folder
*/
gulp.task('dist-remove', function () {
return del(config.release);
});
/**
* Copies files to the dist folder
*/
gulp.task('dist-copy-files', function() {
return gulp.src([
'./app*/**/*',
'./bower_components/**/*',
'./content/**/*',
'./images/**/*',
'./scripts/**/*',
'./manifest-*.xml',
'./index.html',
'./package.json'
], { base: './' }).pipe(gulp.dest(config.release));
});
/**
* Optimizes JavaScript and CSS files
*/
gulp.task('dist-minify', ['dist-minify-js', 'dist-minify-css'], function() {
});
/**
* Minifies and uglifies JavaScript files
*/
gulp.task('dist-minify-js', function() {
gulp.src([
'./app*/**/*.js',
'./scripts/**/*', '!./scripts/MicrosoftAjax.js'
], { base: './' })
.pipe($.uglify())
.pipe(gulp.dest(config.release));
});
/**
* Minifies and uglifies CSS files
*/
gulp.task('dist-minify-css', function() {
gulp.src([
'./app*/**/*.css',
'./content/**/*.css'
], { base: './' })
.pipe($.minifyCss())
.pipe(gulp.dest(config.release));
});
/**
* Creates a release version of the project
*/
gulp.task('dist', function () {
runSequence(
['dist-remove'],
['dist-copy-files'],
['dist-minify']
);
});