-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
100 lines (89 loc) · 2.68 KB
/
gulpfile.js
File metadata and controls
100 lines (89 loc) · 2.68 KB
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
'use strict'
const gulp = require('gulp')
const standard = require('gulp-standard')
const webpack = require('gulp-webpack')
const clean = require('gulp-clean')
const babili = require('gulp-babili')
const htmlmin = require('gulp-htmlmin')
const zip = require('gulp-zip')
gulp.task('standard', function () {
return gulp.src([
'gulpfile.js',
'extension/src/**/*.js',
'firebase/functions/*.js',
'firebase/public/*.js'
])
.pipe(standard({ globals: ['fetch'] }))
.pipe(standard.reporter('default', {
breakOnError: true,
quiet: true
}))
})
gulp.task('prebuild:js', ['standard'], function () {
return gulp.src('extension/build/**/*.js', { read: false })
.pipe(clean())
})
gulp.task('build:js', ['prebuild:js'], function () {
return gulp.src(['extension/src/content_scripts/index.js', 'extension/src/background/index.js'])
.pipe(webpack({
entry: {
contentScripts: './extension/src/content_scripts/index.js',
background: './extension/src/background/index.js'
},
output: {
filename: '[name].js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: [['env', {
targets: {
browsers: 'last 4 Chrome versions'
}
}]]
}
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'htmlts-loader'
}]
}
}))
.pipe(gulp.dest('extension/build'))
})
gulp.task('minify:js', ['build:js'], function () {
return gulp.src('extension/build/**/*.js')
.pipe(babili())
.pipe(gulp.dest('extension/build'))
})
gulp.task('prebuild:html', function () {
return gulp.src('extension/build/**/*.html', { read: false })
.pipe(clean())
})
gulp.task('build:html', ['prebuild:html'], function () {
return gulp.src('extension/src/browser_action/*.html')
.pipe(gulp.dest('extension/build'))
})
gulp.task('minify:html', ['build:html'], function () {
return gulp.src('extension/build/**/*.html')
.pipe(htmlmin({ collapseWhitespace: true, minifyCSS: true, minifyJS: true }))
.pipe(gulp.dest('extension/build'))
})
gulp.task('build', ['build:js', 'build:html'])
gulp.task('minify', ['minify:js', 'minify:html'])
gulp.task('default', ['build'])
gulp.task('prod', ['build', 'minify'])
gulp.task('prepare', ['prod'], () => {
return gulp.src([
'extension/manifest.json',
'extension/icons/**/*',
'extension/vendor/**/*',
'extension/build/*.js',
'extension/build/*.html'
], { base: 'extension' })
.pipe(zip('sccollaborativeplaylists.zip'))
.pipe(gulp.dest('extension/build'))
})