-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGulpfile.js
122 lines (96 loc) · 2.64 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
'use strict';
var gulp = require('gulp');
var del = require('del');
var mocha = require('gulp-mocha');
var sass = require('gulp-sass');
var browserify = require('gulp-browserify');
var shell = require('gulp-shell');
var eslint = require('gulp-eslint');
var scsslint = require('gulp-scss-lint');
gulp.task('clean', function clean(done) {
del(['./build/', './vendor/']);
done();
});
gulp.task('fetch-zepto', shell.task(
'mkdir -p vendor/zeptojs && curl -s https://zeptojs.com/zepto.min.js > vendor/zeptojs/zepto.min.js'
));
gulp.task('fetch-turndown', shell.task(
'mkdir -p vendor/turndown && curl -s https://unpkg.com/[email protected]/dist/turndown.js > vendor/turndown/turndown.js'
));
gulp.task('build:add-vendor-js', gulp.series(
'fetch-zepto',
'fetch-turndown',
(done) => {
gulp
.src('./vendor/**/*.js')
.pipe(gulp.dest('./build/chrome/js/vendor'))
.pipe(gulp.dest('./build/firefox/js/vendor'));
done();
}
));
gulp.task('build:js', function buildJs(done) {
gulp
.src('source/js/*.js')
.pipe(browserify({
insertGlobals: true,
// debug: !gulp.env.production
}))
.pipe(gulp.dest('build/chrome/js'))
.pipe(gulp.dest('build/firefox/js'));
done();
});
gulp.task('build:main', function buildMain(done) {
gulp
.src('source/*.*')
.pipe(gulp.dest('build/chrome'))
.pipe(gulp.dest('build/firefox'));
done();
});
gulp.task('build:images', function buildImages(done) {
gulp
.src('source/images/**')
.pipe(gulp.dest('build/chrome/images'))
.pipe(gulp.dest('build/firefox/images'));
done();
});
gulp.task('build:scss', function buildCss(done) {
gulp
.src('source/styles/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('build/chrome/css'))
.pipe(gulp.dest('build/firefox/css'));
done();
});
gulp.task('lint:js', function lintJs(done) {
gulp
.src('source/js/*.js')
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
done();
});
gulp.task('lint:scss', function lintScss(done) {
gulp
.src('source/**/*.scss')
.pipe(scsslint())
.pipe(scsslint.failReporter());
done();
});
gulp.task('test:unit', function testUnit(done) {
gulp
.src('test/unit/**/*.spec.js')
.pipe(mocha());
done();
});
gulp.task('dev:tdd', function devTdd(done) {
var files = [
'lib/*.js',
'lib/**/*.js',
'test/**/*spec.js'
];
gulp.watch(files, gulp.series('test:unit'));
done();
});
gulp.task('build', gulp.series('build:scss', 'build:js', 'build:main', 'build:images', 'build:add-vendor-js'));
gulp.task('lint', gulp.series('lint:js', 'lint:scss'));
gulp.task('default', gulp.series('build'));