forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (80 loc) · 2.08 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
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
notify = require('gulp-notify'),
sass = require('gulp-sass'),
gulpif = require('gulp-if'),
sassLint = require('gulp-sass-lint'),
browserSync = require('browser-sync').create(),
sourcemaps = require('gulp-sourcemaps'),
exec = require('child_process').exec;
var debug = false;
var assets = 'templates/uno';
/**
* Put relative path to your assets :
* - Wordpress : 'public/wp-content/themes/YOUR_THEME/assets';
* - Symfony : 'public/assets/';
*/
gulp.task('styles', function () {
var output = debug ? 'nested' : 'compressed';
return gulp
.src(assets + '/styles/scss/main.scss')
.pipe(gulpif(debug, sourcemaps.init()))
.pipe(gulpif(debug, sassLint()))
.pipe(gulpif(debug, sassLint.format()))
.pipe(gulpif(debug, sassLint.failOnError()))
.pipe(
sass({ includePaths: ['./node_modules/'], outputStyle: output }).on(
'error',
sass.logError
)
)
.pipe(autoprefixer({ browsers: ['last 2 versions', '> 5%'] }))
.pipe(gulpif(debug, sourcemaps.write()))
.pipe(gulp.dest(assets + '/styles'))
.pipe(notify({ message: 'CSS complete' }));
});
gulp.task('watch', function () {
gulp.watch(
[assets + '/styles/scss/**/*.scss', assets + '/styles/scss/**/*.sass'],
['styles', 'build']
).on('change', function (event) {
browserSync.reload();
console.log(
'File ' +
event.path +
' was ' +
event.type +
', running CSS task...'
);
});
});
gulp.task('default', function () {
gulp.start('styles', 'watch', 'build', 'serve');
});
gulp.task('debug', function () {
debug = true;
gulp.start('styles');
});
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: "./_site"
},
// host: " 172.20.8.240" replace by your current ip to test on another device.
});
});
gulp.task('build', function (cb) {
exec('docfx build', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
/**
* Handle errors and displays them in console
* @param error
*/
function swallowError(error) {
console.log(error.toString());
this.emit('end');
}