-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
138 lines (118 loc) · 3.32 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var typeScript = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var tsProject = typeScript.createProject("tsconfig.json");
var rimraf = require('rimraf');
var header = require('gulp-header');
var typedoc = require("gulp-typedoc");
var paths = {
deps: ['deps/js/**/*.js', 'deps/css/**/*'],
html: ['src/**/*.html'],
scss: ['src/scss/**/*.scss'],
ts: ['src/ts/**/*.ts'],
typeDef: ['src/ts/**/*.d.ts'],
docs: ['index.html', '.nojekyll', 'docs/**/*']
};
var dest = {
root: 'dist/',
js: 'dist/js',
css: 'dist/css',
typeDocOut: 'dist/docs/options'
};
function refreshBrowserSync(done) {
browserSync.reload();
done();
}
// using data from package.json
var pkg = require('./package.json');
var banner = ['/*! <%= pkg.name %>',
' * v<%= pkg.version %>',
' * <%= pkg.homepage %>',
' * @license <%= pkg.license %> */\n'
].join(' | ');
gulp.task('ts', function () {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(header(banner, {
pkg: pkg
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dest.js));
});
gulp.task('html', function () {
return gulp.src(paths.html)
.pipe(gulp.dest(dest.root));
});
gulp.task('ts-watch', ['ts'], refreshBrowserSync);
gulp.task('html-watch', ['html'], refreshBrowserSync);
gulp.task('scss', function () {
return gulp.src(paths.scss)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(dest.css));
});
gulp.task('scss-watch', ['scss'], refreshBrowserSync);
gulp.task('copy-dependency', function () {
return gulp.src(paths.deps, {
base: './deps'
})
.pipe(gulp.dest(dest.root));
});
gulp.task('clean', function () {
return rimraf('dist/**', function () {
// console.log('completed');
});
});
gulp.task('github-pages', function () {
return gulp.src(paths.docs, {
base: '.'
})
.pipe(gulp.dest(dest.root));
});
gulp.task("typedoc", function () {
return gulp
.src(paths.typeDef)
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es5",
includeDeclarations: true,
// Output options (see typedoc docs)
out: dest.typeDocOut,
excludeExternals: true,
readme: 'none',
mode: 'file',
// TypeDoc options (see typedoc docs)
name: pkg.name,
theme: "minimal",
ignoreCompilerErrors: false,
version: true,
}));
});
var taskList = ['copy-dependency', 'scss', 'ts', 'html', 'github-pages', 'typedoc'];
// create a task that ensures the `js` task is complete before
// reloading browsers
gulp.task('watch', taskList, function (done) {
// Serve files from the root of this project
browserSync.init({
ui: {
port: 8080
},
server: {
baseDir: "./dist",
index: "index.html"
}
});
// add browserSync.reload to the tasks array to make
// all browsers reload after tasks are complete.
gulp.watch(paths.ts, ['ts-watch']);
gulp.watch(paths.scss, ['scss-watch']);
gulp.watch(paths.html, ['html-watch']);
gulp.watch(paths.docs, ['github-pages']);
gulp.watch(paths.typeDef, ['typedoc']);
});
gulp.task('deploy-files', taskList);
// use default task to launch Browsersync and watch JS files
gulp.task('default', taskList);