-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (71 loc) · 2.06 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
var gulp = require('gulp'),
minifyCss = require('gulp-minify-css'),
uglifycss = require('gulp-uglifycss'),
concat = require('gulp-concat'),
version = require('gulp-version-number'),
inject = require('gulp-inject'),
sass = require('gulp-sass'),
bump = require('gulp-bump'),
header = require('gulp-header'),
pkg = require('./package.json'),
stripDebug = require('gulp-strip-debug'),
onError = function onError(err) {
console.log(err);
};
var config = {
root: '.',
assets: 'assets',
pages: 'pages'
};
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.v.app %>',
' * @compile-time: ' + new Date().toString(),
' */',
''].join('\n');
gulp.task("sass-compile", function(){
gulp.src([
config.assets + '/scss/import.scss'
])
.pipe(sass().on('error', sass.logError))
.pipe(concat({ path: 'nightknight_stylesheet.css'}))
.pipe(minifyCss({
compatibility: 'ie8',
keepSpecialComments: 0
}))
.pipe(uglifycss({
"max-line-len": 80
}))
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest(config.assets + '/css/minified'));
//Update build-nr
gulp.src(config.root + '/package.json')
.pipe(bump({key: 'v.build', type: 'prerelease', preid: 'compile'}))
.pipe(gulp.dest(config.root));
});
gulp.task('inject-minified', ['sass-compile'], function(){
//Inject in header and footer
var stream = gulp.src(config.pages + '/*.html')
.pipe(
inject(
gulp.src([
config.assets + '/css/minified/*.*',
config.assets + '/css/plugins/**/*.css'
], {
read: false
}
),
{
relative: true
}
)
)
.pipe(gulp.dest(config.pages));
//Callback
return stream;
});
gulp.task('watch', function(){
gulp.watch([
config.assets + '/scss/**/*.scss',
], ['sass-compile', 'inject-minified']);
});