-
Notifications
You must be signed in to change notification settings - Fork 29
/
gulpfile.js
96 lines (85 loc) · 1.98 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
var gulp = require('gulp'),
debug = require('gulp-debug'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
minify = require('gulp-minify-css'),
rename = require('gulp-rename'),
express = require('express');
/* Constants. */
var components = './bower_components';
var bootstrap = components + '/bootstrap/dist';
var bootswatch = components + '/bootswatch';
var theme = bootswatch + '/readable';
var src = {
css: theme + '/bootstrap.css',
js: bootstrap + '/js/bootstrap.{js,min.js}',
icons: bootstrap + '/fonts/*.{eot,svg,ttf,woff,woff2}',
sass: './sass/*.{sass,scss}',
};
var dist = {
css: './css',
fonts: './fonts',
js: './js'
};
/* Build sass stylesheets. */
gulp.task('sass', function () {
gulp.src(src.sass)
.pipe(sass())
.pipe(sourcemaps.init())
.pipe(minify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist.css))
.pipe(debug());
});
/* Copy stylesheets from components. */
gulp.task('css', function () {
gulp.src(src.css)
.pipe(gulp.dest(dist.css))
.pipe(debug())
.pipe(sourcemaps.init())
.pipe(minify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist.css))
.pipe(debug());
});
/* Copy js from components. */
gulp.task('js', function () {
gulp.src(src.js)
.pipe(gulp.dest(dist.js))
.pipe(debug());
});
/* Copy icon fonts from components. */
gulp.task('icons', function () {
gulp.src(src.icons)
.pipe(gulp.dest(dist.fonts))
.pipe(debug());
});
/* Build all assets. */
gulp.task('assets', [
'css',
'js',
'icons',
'sass']);
/* Development server. */
gulp.task('develop', function () {
var app = express();
app.use(express.static('./'));
var server = app.listen(3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Live at http://%s:%s', host, port);
});
});
/* Default task. */
gulp.task('default', [
'assets',
'develop'
], function () {
gulp.watch(src.sass, ['sass']);
});