-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
92 lines (80 loc) · 2.82 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
/**
* Desctop Caputure Recorderビルドスクリプト
*/
// config
// *** chromeの拡張機能
var clientBase = 'client/';
var popupSassFiles = clientBase + 'scss/*.scss';
var popupSassBuildDir = clientBase + 'build/css/';
var popupScriptFiles = ['client/js/class.js', 'client/js/knockout.js', 'client/js/popup.js'];
var popupScriptBuildDir = clientBase + 'build/js/';
var bgScriptFiles = ['client/js/class.js', 'client/js/RecordRTC.js', 'client/js/gif-recorder.js', 'client/js/capture_recorder.js', 'client/js/background.js'];
var bgScriptBuildDir = clientBase + 'build/js/';
var clientHtmlFiles = clientBase + 'html/*.html';
var clientHtmlBuildDir = clientBase + 'build/html/';
// requires
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var minifyHtml = require('gulp-minify-html');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var minifyInline = require('gulp-minify-inline');
var runSequence = require('run-sequence');
/**
* Google Chrome App タスク
*/
// popup用cssの生成
gulp.task('build-client-popup-sass', function() {
gulp.src(popupSassFiles)
.pipe(sass())
.pipe(concat('popup.css'))
.pipe(gulp.dest(popupSassBuildDir))
.pipe(minifyCss())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest(popupSassBuildDir));
});
// popup用jsの生成
gulp.task('build-client-popup-script', function() {
gulp.src(popupScriptFiles)
.pipe(concat('popup.js'))
.pipe(gulp.dest(popupScriptBuildDir))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(popupScriptBuildDir));
});
// background用jsの生成
gulp.task('build-client-bg-script', function() {
gulp.src(bgScriptFiles)
.pipe(concat('background.js'))
.pipe(gulp.dest(bgScriptBuildDir))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(bgScriptBuildDir));
});
// web用htmlの生成
gulp.task('build-client-html', function () {
// knockout.jsを使ってるので comments: trueは必須
var minifyHtmlOption = {comments: true, quotes: true, spare: false, empty: true};
gulp.src(clientHtmlFiles)
.pipe(minifyHtml(minifyHtmlOption))
.pipe(gulp.dest(clientHtmlBuildDir));
});
// ウォッチャー
gulp.task('build-client-watch', function() {
gulp.watch(popupSassFiles, function(event) {
gulp.run('build-client-popup-sass');
});
gulp.watch(popupScriptFiles, function(event) {
gulp.run('build-client-popup-script');
});
gulp.watch(bgScriptFiles, function(event) {
gulp.run('build-client-bg-script');
});
gulp.watch(clientHtmlFiles, function(event) {
gulp.run('build-client-html');
});
});
// 全て実行
gulp.task('build-client', ['build-client-popup-sass', 'build-client-popup-script', 'build-client-bg-script', 'build-client-html']);