Skip to content

Commit 87f0cb9

Browse files
committed
Update gulpfile to bundle new ts project
1 parent 41084b3 commit 87f0cb9

File tree

3 files changed

+2340
-221
lines changed

3 files changed

+2340
-221
lines changed

gulpfile.js

Lines changed: 66 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1-
var gulp = require('gulp'),
1+
const gulp = require('gulp'),
22
$ = require('gulp-load-plugins')(),
33
path = require('path'),
44
minimatch = require('minimatch'),
55
through2 = require('through2'),
66
del = require('del'),
7-
inquirer = require('inquirer'),
8-
sprite = require('css-sprite').stream;
9-
10-
11-
var paths = {
7+
inquirer = require('inquirer');
8+
// sprite = require('css-sprite').stream,
9+
ts = require('gulp-typescript'),
10+
tsProject = ts.createProject('tsconfig.json');
11+
12+
const distRoot = path.resolve('./distv2')
13+
const scriptRoot = path.join(distRoot, 'js')
14+
const styleRoot = path.join(distRoot, 'css')
15+
const imageRoot = path.join(distRoot, 'image')
16+
const paths = {
1217
dist: {
13-
root: './dist'
18+
root: distRoot,
19+
scripts: scriptRoot,
20+
styles: {
21+
root: styleRoot,
22+
dataURI: path.join(styleRoot, 'data-uri'),
23+
sprites: path.join(styleRoot, 'sprites'),
24+
basic: path.join(styleRoot, 'basic')
25+
},
26+
images: {
27+
root: imageRoot,
28+
separate: path.join(imageRoot, 'basic'),
29+
sprites: path.join(imageRoot, 'sprites')
30+
}
1431
}
15-
};
16-
paths.dist.scripts = path.join(paths.dist.root, 'js');
17-
paths.dist.styles = { root: path.join(paths.dist.root, 'css') };
18-
paths.dist.styles.dataURI = path.join(paths.dist.styles.root, 'data-uri');
19-
paths.dist.styles.sprites = path.join(paths.dist.styles.root, 'sprites');
20-
paths.dist.styles.basic = path.join(paths.dist.styles.root, 'basic');
21-
paths.dist.images = { root: path.join(paths.dist.root, 'images') };
22-
paths.dist.images.separate = path.join(paths.dist.images.root, 'basic');
23-
paths.dist.images.sprites = path.join(paths.dist.images.root, 'sprites');
24-
25-
gulp.task('default', ['compile']);
26-
27-
gulp.task('compile', ['script', 'images-and-styles']);
28-
29-
gulp.task('release', ['update', 'compile', 'bump']);
30-
31-
gulp.task('script', function(){
32-
var pkg = require('./package.json');
33-
34-
gulp.src('./src/emojify.js')
35-
.pipe(gulp.dest(paths.dist.scripts))
36-
.pipe($.jshint())
37-
.pipe($.jshint.reporter('jshint-stylish'))
32+
}
33+
exports.default = compile
34+
35+
function compile () {
36+
return gulp.series(scripts, imageAndStyles)
37+
}
38+
exports.compile = compile
39+
40+
function release () {
41+
return gulp.series(update, compile, bump)
42+
}
43+
exports.release = release
44+
45+
function scripts () {
46+
const pkg = require('./package.json');
47+
return tsProject.src()
48+
.pipe(tsProject())
49+
.js
50+
// TODO: Do tslint
51+
// .pipe($.jshint())
52+
// .pipe($.jshint.reporter('jshint-stylish'))
3853
.pipe($.insert.prepend('/*! ' + pkg.name + ' - v' + pkg.version + ' - \n' +
3954
' * Copyright (c) Hassan Khan ' + new Date().getFullYear() + '\n' +
4055
' */'))
@@ -45,7 +60,8 @@ gulp.task('script', function(){
4560
suffix: '.min'
4661
}))
4762
.pipe(gulp.dest(paths.dist.scripts));
48-
});
63+
}
64+
exports.scripts = scripts
4965

5066
var getEmoticonFilter = function(){
5167
var emoticons = [
@@ -63,10 +79,9 @@ var getEmoticonFilter = function(){
6379
})
6480
};
6581

66-
gulp.task('images-and-styles', ['copy-styles', 'data-uri'], function(){
67-
68-
69-
var emoticonFilter = getEmoticonFilter(),
82+
function imageAndStyles () {
83+
return gulp.series(copyStyles, dataURI, function () {
84+
var emoticonFilter = getEmoticonFilter(),
7085
cssFilter = $.filter('**.css'),
7186
emoticonCssFilter = $.filter('**.css'),
7287
emoticonPngFilter = $.filter('**.png');
@@ -126,9 +141,11 @@ gulp.task('images-and-styles', ['copy-styles', 'data-uri'], function(){
126141
.pipe(cssFilter.restore())
127142
.pipe($.filter('**.png'))
128143
.pipe(gulp.dest(paths.dist.images.sprites));
129-
});
144+
})
145+
}
146+
exports.imageAndStyles = imageAndStyles
130147

131-
gulp.task('data-uri', function(){
148+
function dataURI () {
132149
var emoticonFilter = getEmoticonFilter();
133150

134151
return gulp.src('./src/images/emoji/*.png')
@@ -158,24 +175,25 @@ gulp.task('data-uri', function(){
158175
suffix: '.min'
159176
}))
160177
.pipe(gulp.dest(paths.dist.styles.dataURI));
161-
});
178+
}
162179

163-
gulp.task('copy-styles', function(){
180+
function copyStyles (){
164181
gulp.src('./src/css/basic/*.css')
165182
.pipe(gulp.dest(paths.dist.styles.basic))
166183
.pipe($.minifyCss())
167184
.pipe($.rename({
168185
suffix: '.min'
169186
}))
170187
.pipe(gulp.dest(paths.dist.styles.basic));
171-
});
188+
}
172189

173-
gulp.task('clean', function(done){
190+
function clean (done) {
174191
del(paths.dist.root, done);
175-
});
192+
}
193+
exports.clean = clean
176194

177195

178-
gulp.task('bump', function(done){
196+
function bump (done) {
179197
inquirer.prompt({
180198
type: 'list',
181199
name: 'bump',
@@ -192,9 +210,10 @@ gulp.task('bump', function(done){
192210
.pipe(gulp.dest('./'))
193211
.on('end', done);
194212
});
195-
});
213+
}
214+
exports.bump = bump
196215

197-
gulp.task('update', function(done){
216+
function update (done) {
198217
var emoji = '';
199218

200219
del('./src/images/emoji');
@@ -216,4 +235,5 @@ gulp.task('update', function(done){
216235
.pipe(gulp.dest('./src'))
217236
.on('end', done);
218237
}));
219-
});
238+
}
239+
exports.update = update

0 commit comments

Comments
 (0)