forked from connor/Domai.nr-Chrome-Extension
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
74 lines (63 loc) · 1.83 KB
/
Copy pathgulpfile.js
File metadata and controls
74 lines (63 loc) · 1.83 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
/* globals process, console */
'use strict';
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var replace = require('gulp-replace');
var gulpif = require('gulp-if');
var del = require('del');
var httpServer = require('http-server');
var openBrowser = require('opener');
var minifyCss = require('gulp-minify-css');
var dest = './build/';
var apiKey = process.env.DOMAINR_CHROME_API_KEY;
// ----------
gulp.task('serve', ['watch'], function() {
var port = process.env.PORT || 3102;
var server = httpServer.createServer();
return server.listen(port, 'localhost', function () {
console.log('Server listening at http://localhost:' + port);
openBrowser('http://localhost:' + port + '/domainr.html');
});
});
// ----------
gulp.task('watch', ['build'], function() {
return gulp.watch(['js/*.*', 'stylesheets/*.*'], ['build']);
});
// ----------
gulp.task('js', function() {
var scripts = [
'./node_modules/domainr-search-box/dist/domainr-search-box.min.js',
'./js/script.js'
];
return gulp.src(scripts)
.pipe(gulpif(function(file) {
return !(/domainr-search-box/).test(file.path);
}, uglify()))
.pipe(concat('script.js'))
.pipe(replace(/{your-api-key-goes-here}/g, apiKey))
.pipe(gulp.dest(dest));
});
// ----------
gulp.task('css', function() {
var styles = [
'./node_modules/domainr-search-box/dist/domainr-search-box.css',
'./stylesheets/styles.css'
];
return gulp.src(styles)
.pipe(gulpif(function(file) {
return !(/domainr-search-box/).test(file.path);
}, minifyCss()))
.pipe(concat('styles.css'))
.pipe(gulp.dest(dest));
});
// ----------
gulp.task('clean', function () {
return del([
'build/**/*'
]);
});
// ----------
gulp.task('build', ['clean', 'js', 'css']);
// ----------
gulp.task('default', ['serve']);