This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Gulpfile.js
116 lines (107 loc) · 3.02 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
connect = require('gulp-connect'),
uglify = require('gulp-uglifyes'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
babelify = require('babelify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
browserify = require('browserify');
gulp.task('sass', function() {
gulp
.src('./source/app/*.scss')
.pipe(sass())
.pipe(gulp.dest('./extension/dist/'))
.pipe(connect.reload());
});
gulp.task('production-sass', function() {
gulp
.src('./source/app/*.scss')
.pipe(sass())
.pipe(cleanCSS())
.pipe(gulp.dest('./extension/dist/'));
});
gulp.task('production-app', () => {
console.log('This process will take a several minutes, feel free to have a coffee.');
var bundler = browserify({
entries: ['./source/app/app.js'],
debug: false
}).transform(babelify, { presets: ['es2015', 'react'] });
return bundler
.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(
uglify({
mangle: false,
ecma: 5
})
)
.pipe(gulp.dest('./extension/dist/'));
});
gulp.task('production-bg', () => {
var bundler = browserify({
entries: ['./source/background/background.js'],
debug: false
}).transform(babelify, { presets: ['es2015'] });
return bundler
.bundle()
.pipe(source('background.js'))
.pipe(buffer())
.pipe(
uglify({
mangle: false,
ecma: 5
})
)
.pipe(gulp.dest('./extension/js'));
});
gulp.task('dev-app', () => {
var bundler = browserify({
entries: ['./source/app/app.js'],
debug: true
}).transform(babelify, { presets: ['es2015', 'react'] });
return bundler
.bundle()
.on('error', err => {
console.log(err.message);
})
.pipe(source('app.js'))
.pipe(gulp.dest('./extension/dist/'))
.pipe(connect.reload());
});
gulp.task('dev-bg', () => {
var bundler = browserify({
entries: ['./source/background/background.js'],
debug: true
}).transform(babelify, { presets: ['es2015'] });
return bundler
.bundle()
.on('error', err => {
console.log(err.message);
})
.pipe(source('background.js'))
.pipe(gulp.dest('./extension/js'))
.pipe(connect.reload());
});
// if dev build is falling on this task, just try to change port number - its reported bug of gulp-connect
gulp.task('connect', () => {
connect.server({
root: 'app',
port: 3014,
livereload: true
});
});
gulp.task('html', () => {
gulp.src('./extension/*.html').pipe(connect.reload());
});
gulp.task('watch', () => {
gulp.watch('./source/background/**/*.js', ['dev-bg']);
gulp.watch('./source/app/index.html', ['html']);
gulp.watch('./source/app/**/*.scss', ['sass']);
gulp.watch('./source/app/**/*.js', ['dev-app']);
});
gulp.task('default', ['production-app', 'production-bg', 'sass']);
gulp.task('serve', ['dev-bg', 'dev-app', 'sass', 'connect', 'watch']);
gulp.task('production', ['production-app', 'production-bg', 'production-sass']);