-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (51 loc) · 1.63 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));
var browserSync = require('browser-sync').create();
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var rtlcss = require('gulp-rtlcss');
var gulpif = require('gulp-if');
// RTL
var enableRTL = false; // TODO: RTL CSS will be only generated if this is TRUE
// Paths
var Paths = {
TEMPLATE: './template',
SCSS: 'template/assets/scss/**/*.scss',
CSS: 'template/assets/css/',
JS: 'template/**/*.js',
HTML: 'template/**/*.html'
}
// Compile sass into CSS
gulp.task('sass', function() {
return gulp.src(Paths.SCSS)
.pipe(sourcemaps.init())
.pipe(sass.sync({
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(autoprefixer({
overrideBrowserslist: ['last 2 versions']
}))
.pipe(gulp.dest(Paths.CSS))
.pipe(gulpif(enableRTL, rtlcss()))
.pipe(gulpif(enableRTL, rename({ suffix: '-rtl' })))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Paths.CSS))
.pipe(browserSync.stream());
});
// Static Server
gulp.task('serve', function(done) {
browserSync.init({
server: Paths.TEMPLATE
});
done();
});
// watching files
gulp.task('watch', function(done) {
gulp.watch(Paths.SCSS).on('change', gulp.series('sass'));
gulp.watch(Paths.HTML).on('change', browserSync.reload);
gulp.watch(Paths.JS).on('change', browserSync.reload);
done();
});
gulp.task('default', gulp.series('sass', 'serve', 'watch'));