forked from kylekeppler/sphinx_redactor_theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
112 lines (97 loc) · 2.48 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
109
110
111
(function () {
'use strict';
const gulp = require('gulp');
const gutil = require('gulp-util');
const jshint = require('gulp-jshint');
const minify = require('gulp-minify');
const sass = require('gulp-sass');
const scsslint = require('gulp-scss-lint');
const connect = require('gulp-connect');
const exec = require('child_process').exec;
const autoprefixer = require('gulp-autoprefixer');
const src_dir = __dirname + '/demo_docs/';
const dist_dir = src_dir + 'build/html/';
const theme_dir = __dirname + '/sphinx_redactor_theme/';
const static_dir = theme_dir + 'static/';
const paths = {
'templates': theme_dir,
'css': static_dir + 'css/',
'js': __dirname + '/js/',
'sass': __dirname + '/sass/',
};
const patterns = {
'sass': [
paths.sass + '*.scss',
paths.sass + '_*.scss',
paths.sass + '**/*.scss'
],
'css': [
paths.css + 'redactor.css',
],
'js': [
paths.js + '*.js',
],
'templates': [
paths.templates + '*.html',
]
};
gulp.task('jslint', function() {
gulp.src(patterns.js)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('jscompress', function() {
gulp.src(patterns.js)
.pipe(minify({
noSource: true,
mangle: true
}))
.pipe(gulp.dest(static_dir + 'js/'));
});
gulp.task('prefixer', function() {
return gulp.src(patterns.css)
.pipe(autoprefixer())
.pipe(gulp.dest(paths.css));
});
gulp.task('sass', function () {
return gulp.src(patterns.sass)
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(gulp.dest(paths.css));
});
gulp.task('scsslint', function() {
if(gutil.env.exitonerror === 1)
gulp.src(patterns.sass)
.pipe(scsslint({
'config': 'scss-lint.yml',
}))
.pipe(scsslint.failReporter());
else
gulp.src(patterns.sass)
.pipe(scsslint({
'config': 'scss-lint.yml',
}))
.on('error', function(error) {
gutil.log(error);
});
});
gulp.task('build', function() {
process.chdir(src_dir);
exec('make html', function (err, stdout, stderr) {});
});
gulp.task('default', function () {
gulp.start('scsslint');
gulp.start('sass');
gulp.start('prefixer');
gulp.start('jslint');
gulp.start('jscompress');
gulp.watch(patterns.sass, ['scsslint']);
gulp.watch(patterns.sass, ['sass']);
gulp.watch(patterns.css, ['build']);
gulp.watch(patterns.templates, ['build']);
gulp.watch(patterns.js, ['jslint']);
gulp.watch(patterns.js, ['jscompress']);
});
// end of gulpfile.js
}());