-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
76 lines (63 loc) · 1.88 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
var gulp = require('gulp'),
browserify = require('browserify'),
eslint = require('gulp-eslint'),
jscs = require('gulp-jscs'),
uglify = require('gulp-uglify'),
source = require('vinyl-source-stream'),
mochaPhantomJS = require('gulp-mocha-phantomjs'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
files = [ './lib/**/*.js' ],
buildDir = './build';
gulp.task('lint', function() {
return gulp.src(files)
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('jscs', function() {
return gulp.src(files)
.pipe(jscs());
});
gulp.task('browserify', function() {
var browserifyBundler = browserify('./lib/index.js', {
debug: false,
transform: [ 'reactify' ]
});
return browserifyBundler.bundle()
.pipe(source('codebasket.js'))
.pipe(gulp.dest(buildDir));
});
gulp.task('sass', function() {
gulp.src('./sass/index.scss')
.pipe(sass().on('error', sass.logError))
.pipe(rename('codebasket.css'))
.pipe(gulp.dest(buildDir));
});
gulp.task('copy_assets', function() {
gulp.src('./sass/fonts/**/*')
.pipe(gulp.dest(buildDir + '/fonts'));
});
gulp.task('dist', [ 'browserify', 'sass', 'copy_assets' ], function() {
return gulp.src(buildDir + '/codebasket.js')
.pipe(uglify())
.pipe(gulp.dest(buildDir));
});
gulp.task('test', function() {
return gulp.src('./test/index.html')
.pipe(mochaPhantomJS());
});
gulp.task('build', [ 'lint', 'jscs', 'browserify', 'sass', 'copy_assets' ], function() {
var argv = require('yargs').argv;
if (argv['copy-js']) {
gulp.src(buildDir + '/codebasket.js')
.pipe(gulp.dest(argv['copy-js']));
}
if (argv['copy-css']) {
gulp.src(buildDir + '/codebasket.css')
.pipe(gulp.dest(argv['copy-css']));
}
});
gulp.task('watch', function() {
gulp.watch(files.concat('./sass/**/*.scss'), [ 'build' ]);
});
gulp.task('default', [ 'build', 'watch' ]);