-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
69 lines (56 loc) · 1.65 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var jsoncombine = require('gulp-jsoncombine');
var del = require('del');
var runSequence = require('run-sequence');
var paths = {
files: ['images/**/*', 'js/**/*'],
sass: 'sass/main.scss',
manifest: 'manifest.json',
ffmanifest: 'firefox-manifest.json',
dest: {
chrome: 'dist/chrome',
firefox: 'dist/firefox'
}
};
var ffmanifest = {
"applications": {
"gecko": {
"id": "[email protected]"
}
}
}
function clean() {
return del('dist');
}
function copyFiles() {
return gulp.src(paths.files, { "base": "."})
.pipe(gulp.dest(paths.dest.chrome))
.pipe(gulp.dest(paths.dest.firefox));
}
function sassTask() {
return gulp.src(paths.sass)
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest(paths.dest.chrome + '/css'))
.pipe(gulp.dest(paths.dest.firefox + '/css'));
}
function firefoxManifest(data, meta) {
data.manifest.applications = ffmanifest.applications;
return new Buffer(JSON.stringify(data.manifest));
}
function copyManifest() {
return gulp.src(paths.manifest)
.pipe(gulp.dest(paths.dest.chrome))
.pipe(jsoncombine('manifest.json', firefoxManifest))
.pipe(gulp.dest(paths.dest.firefox));
}
gulp.task('clean', clean);
gulp.task('copy', copyFiles);
gulp.task('sass', sassTask);
gulp.task('manifest', copyManifest);
gulp.task('default', function(done) {
runSequence('clean', 'copy', 'sass', 'manifest', done);
});
gulp.task('watch', function() {
gulp.watch(['sass/**/*.scss', 'js/**/*.js', 'images/**/*', 'manifest.json'], ['default']);
});