-
Notifications
You must be signed in to change notification settings - Fork 22
/
gulpfile.js
108 lines (94 loc) · 2.39 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
97
98
99
100
101
102
103
104
105
106
107
108
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
del = require('del'),
browserSync = require('browser-sync'),
path = require('path'),
exec = require('child_process').exec,
reload = browserSync.reload,
sourcemaps = require('gulp-sourcemaps');
const SASS_SOURCES = [
'src/**/*.scss'
];
const SASS_INCLUDE_PATHS = [
path.join(__dirname, '/node_modules/')
];
const NODE_SASS_OPTIONS = {
includePaths: SASS_INCLUDE_PATHS,
outputStyle: "expanded",
precision: 6
};
const AUTOPREFIXER_OPTIONS = {
browsers: ['last 2 versions'],
cascade: false
};
const STATIC_FILES = [
'src/static/*.html',
'src/static/*.pdf',
'src/static/*.css'
];
const FILES_TO_WATCH = [
'**/*.rst',
'**/*.html',
'**/*.tmpl',
'files/*'
];
gulp.task('styles', function () {
gulp.src(SASS_SOURCES)
.pipe(sourcemaps.init())
.pipe(sass(NODE_SASS_OPTIONS).on('error', sass.logError))
.pipe(autoprefixer(AUTOPREFIXER_OPTIONS))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('files/'))
.pipe(browserSync.stream());
});
gulp.task('assets-js', function () {
gulp.src('src/js/*.js')
.pipe(gulp.dest('files/js/'))
.pipe(browserSync.stream());
});
gulp.task('assets-fonts', function () {
gulp.src('src/fonts/*')
.pipe(gulp.dest('files/fonts/'))
.pipe(browserSync.stream());
});
gulp.task('assets', function () {
gulp.src(STATIC_FILES)
.pipe(gulp.dest('files/static/'))
.pipe(browserSync.stream());
});
gulp.task('nikola-build', function (cb) {
exec('nikola build', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('nikola-clean', function (cb) {
exec('nikola clean', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('build', [
'styles',
'assets',
'assets-js',
'assets-fonts',
'nikola-build'
]);
gulp.task('clean', ['nikola-clean'], function () {
del(['files/**']);
});
gulp.task('start', ['build'], function () {
browserSync({
server: {
baseDir: 'output/'
}
});
gulp.watch(SASS_SOURCES, ['styles']);
gulp.watch(FILES_TO_WATCH, ['nikola-build']);
});
gulp.task('default', ['build']);