-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·75 lines (67 loc) · 2.1 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
var fs = require('fs');
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var watch = require('gulp-watch');
var jshint = require('gulp-jshint');
require('jshint-stylish');
gulp.task('watch', function() {
gulp.watch(['src/**/*.coffee'], ['coffee']);
});
gulp.task('observe', function() {
gulp.watch(['src/**/*.coffee'], ['copy']);
});
gulp.task('coffee', function() {
var coffeeStream = coffee({bare: true, sourceMap: false});
coffeeStream.on('error', function(){
console.log('!!! Error');
console.log(arguments);
coffeeStream.emit('end');
});
return gulp.src(['src/**/*.coffee'])
.pipe(coffeeStream)
.pipe(gulp.dest('build/'));
});
gulp.task('jshint', function() {
return gulp.src('build/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
});
gulp.task('optimize', ['coffee'],function(cb){
var requirejs = require('requirejs');
var config = {
baseUrl: "build/public",
optimize: "none",
paths: {
q: "vendor/q",
objectpath: "vendor/objectpath"
},
exclude: [ "q" ],
name: "parser",
out: "build/dist/dparser.min.js"
};
requirejs.optimize(config, function (buildResponse) {
console.log( buildResponse);
//buildResponse is just a text output of the modules
//included. Load the built file for the contents.
//Use config.out to get the optimized file contents.
cb();
}, function(err) {
//optimization err callback
console.log( err );
cb(err);
});
});
gulp.task('copy', ['optimize'],function(cb){
var config = {
out: "build/dist/dparser.min.js"
};
var oldFile = fs.createReadStream(config.out);
var newFile = fs
.createWriteStream('/Users/c301/Job/chrome-extension/src/js/syndication/dparser.js');
oldFile.on('end', function () {
console.log('Copy end');
cb();
});
oldFile.pipe(newFile);
});