This repository has been archived by the owner on Sep 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
61 lines (54 loc) · 1.75 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
'use strict'
var del = require('del')
var gulp = require("gulp");
var gulpif = require("gulp-if")
var minifyCss = require('gulp-minify-css')
var zip = require('gulp-zip')
var change = require('gulp-change')
gulp.task('clean-chrome', (cb) => {
return del(['chrome', 'chrome.zip'])
})
gulp.task('change-html', ['clean-chrome'], (cb) => {
let performChange = (content) => {
return content.replace('<script src="http://localhost:7070/webpack-dev-server.js"></script>', '').replace('http://localhost:7070/assets/index.js', 'dist/index.js')
}
return gulp.src('index.html')
.pipe(change(performChange))
.pipe(gulp.dest('chrome'))
})
gulp.task('change-manifest', ['change-html'], (cb) => {
let performChange = (content) => {
return content.replace(' http://localhost:7070/assets/index.js', '').replace(' http://localhost:7070/webpack-dev-server.js', '')
}
return gulp.src('manifest.json')
.pipe(change(performChange))
.pipe(gulp.dest('chrome'))
})
gulp.task('extract-files', ['change-manifest'], (cb) => {
let cssFilter = function (file) {
if (file.path.match(/\.css$/)) {
return true
}
}
return gulp.src([
'dist/**/*.*',
'images/**/*.*',
'js/**/*.*',
'dev/libs/bootstrap/**/*.*'
], {base: './'})
.pipe(gulpif(cssFilter, minifyCss()))
.pipe(gulp.dest('chrome'))
.pipe(zip('chrome.zip'))
.pipe(gulp.dest('.'))
})
gulp.task('release', ['extract-files'], (cb) => {
let cssFilter = function (file) {
if (file.path.match(/\.css$/)) {
return true
}
}
return gulp.src(['chrome/**/*.*'])
.pipe(zip('chrome.zip'))
.pipe(gulp.dest('.'))
})
gulp.start('release')