-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
203 lines (183 loc) · 5 KB
/
gulpfile.babel.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import gulp from 'gulp';
import gulpSequence from 'gulp-sequence';
import tslint from 'gulp-tslint';
import gutil from 'gulp-util';
import sass from 'gulp-sass';
import typescript from 'gulp-typescript';
import uglify from 'gulp-uglify';
import connect from 'gulp-connect';
import concat from 'gulp-concat';
import del from 'del';
import sassLint from 'gulp-sass-lint';
import typedoc from 'gulp-typedoc';
import browserify from 'browserify';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
gulp.task('clean:dist', () => {
gutil.log('== Cleaning dist ==');
return del(['dist/**/*']);
});
gulp.task('clean:docs', () => {
gutil.log('== Cleaning docs ==');
return del(['docs/**/*']);
});
gulp.task('clean:temp', () => {
gutil.log('== Cleaning temp ==');
return del(['dist/js-pure/**/*.*']);
});
gulp.task('readme', () => {
gutil.log('== Assembling documentation files ==');
return gulp.src(['src/**/*.ts'])
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: 'commonjs',
target: 'es5',
excludeExternals: true,
includeDeclarations: true,
// Output options (see typedoc docs)
out: './docs',
// TypeDoc options (see typedoc docs)
name: 'planet-funk',
theme: 'markdown',
plugins: ['mdFlavour bitbucket'],
ignoreCompilerErrors: false,
version: true,
}));
});
gulp.task('tslint', () => {
gutil.log('== Lintifying the ts files ==');
gulp.src('src/**/*.ts')
.pipe(tslint({
formatter: 'verbose'
}))
.pipe(tslint.report())
});
gulp.task('sasslint', () => {
gutil.log('== Lintifying the ts files ==');
gulp.src(['src/scss/**/*.s+(a|c)ss'])
.pipe(sassLint({
options: {
formatter: 'stylish'
},
files: {ignore: 'src/scss/reset_author_richard_clark.scss'},
rules: {
'hex-length': [
2, // Severity 2 (error)
{
'style': 'long'
}
],
'no-color-literals': 0,
'no-ids': 0,
'no-mergeable-selectors': 0,
'no-vendor-prefixes': [
1, // Severity 1 (warning)
{
'excluded-identifiers': [
'webkit',
'moz'
]
}
]
}
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
gulp.task('html', () => {
gutil.log('== Copying index.html to dist ==');
gulp.src('src/index.html')
.pipe(gulp.dest('dist'))
.pipe(connect.reload())
});
gulp.task('assets', () => {
gutil.log('== Copying index.html to dist ==');
gulp.src('src/assets/**/*')
.pipe(gulp.dest('dist/assets'))
.pipe(connect.reload())
});
gulp.task('typescript', () => {
gutil.log('== Transmogrifying ts to js ==');
return gulp.src('src/**/*.ts')
.pipe(typescript({
noImplicitAny: true,
sourceMap: true,
module: "commonjs"
}))
.on('error', gutil.log)
.pipe(gulp.dest('dist/js-pure'));
});
gulp.task('bundle', () => {
gutil.log('== Bundling the js ==');
return browserify('./dist/js-pure/index.js')
.on('error', gutil.log)
.bundle()
.on('error', gutil.log)
.pipe(source('bundle.js'))
.on('error', gutil.log)
.pipe(buffer())
.pipe(gulp.dest('./dist/js-pure/'))
});
gulp.task('fuglify', () => {
gutil.log('== Fuglifying the js ==');
return gulp.src('dist/js-pure/bundle.js')
.pipe(uglify())
.on('error', gutil.log)
.pipe(gulp.dest('dist/js'));
});
gulp.task('sass', () => {
gutil.log('== Converting scss to css ==');
gulp.src([
'src/scss/reset_author_richard_clark.scss',
'src/scss/**/*.scss'
])
.pipe(sass({style: 'expanded'}))
.on('error', gutil.log)
.pipe(concat('styles.css'))
.on('error', gutil.log)
.pipe(gulp.dest('dist/css'))
.pipe(connect.reload())
});
gulp.task('scripts:reload', (callback) => {
gulpSequence('clean:temp', 'typescript', 'bundle', 'fuglify', 'reload')(callback);
});
gulp.task('connect', () => {
gutil.log('== Opening live reload server ==');
connect.server({
root: 'dist',
livereload: true
})
});
gulp.task('reload', () => {
gutil.log('== reloading ==');
return gulp.src('dist/index.html')
.pipe(connect.reload());
});
gulp.task('watch', () => {
gulp.watch('src/assets/**/*', ['assets']);
gulp.watch('src/ts/**/*.ts', ['scripts:reload']);
gulp.watch('src/scss/**/*.scss', ['sass']);
gulp.watch('src/index.html', ['html']);
});
gulp.task('build', gulpSequence(
'clean:dist',
['tslint', 'sasslint'],
['assets', 'html', 'sass', 'typescript'],
'bundle',
'fuglify'
));
gulp.task('typedoc', gulpSequence(
'clean:docs',
'readme'
));
gulp.task('lint', gulpSequence(
['tslint', 'sasslint']
));
gulp.task('default', gulpSequence(
'clean:dist',
['assets', 'html', 'sass', 'typescript'],
'bundle',
'fuglify',
'connect',
'watch'
));