-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
83 lines (71 loc) · 1.96 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var rename = require("gulp-rename");
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifyHTML = require('gulp-minify-html');
var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
gulp.task('minify-html', function() {
var opts = {
conditionals: true,
spare:true
};
return gulp.src('./edit_index.html')
.pipe(minifyHTML(opts))
.pipe(rename('index.html'))
.pipe(gulp.dest('./'));
});
gulp.task('scripts', function() {
gulp.src(['./utils.js', './js/**/*.js', './updateManager.js', './index.js'])
.pipe(sourcemaps.init())
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write())
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('scss', function() {
return gulp.src(['./scss/index.scss', './scss/vender/*'])
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(autoprefixer({
browsers: AUTOPREFIXER_BROWSERS,
cascade: false
}))
.pipe(minifyCSS())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function () {
gulp.watch(['./utils.js', './index.js', './js/**/*.js'], ['scripts']);
gulp.watch('./scss/**/*.scss', ['scss']);
gulp.watch('./edit_index.html', ['minify-html']);
});
gulp.task('bg-js', function() {
gulp.src(['./bg_scripts/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('background.js'))
.pipe(sourcemaps.write())
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('bg', function() {
gulp.watch('./bg_scripts/**/*.js', ['bg-js']);
});
gulp.task('default', ['scripts', 'scss', 'minify-html', 'watch']);