forked from Koha-Community/Koha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (50 loc) · 1.6 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
/* eslint-env node */
/* eslint no-console:"off" */
let gulp;
try {
gulp = require( "gulp" );
} catch(e) {
console.error("You are missing required Node modules; run `npm install`.");
process.exit(1);
}
const gutil = require( "gulp-util" );
const sass = require("gulp-sass");
const cssnano = require("gulp-cssnano");
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const STAFF_JS_BASE = "koha-tmpl/intranet-tmpl/prog/js";
const STAFF_CSS_BASE = "koha-tmpl/intranet-tmpl/prog/css";
const OPAC_JS_BASE = "koha-tmpl/opac-tmpl/bootstrap/js";
const OPAC_CSS_BASE = "koha-tmpl/opac-tmpl/bootstrap/css";
var sassOptions = {
errLogToConsole: true,
precision: 3
}
if( gutil.env.view == "opac" ){
var css_base = OPAC_CSS_BASE;
var js_base = OPAC_JS_BASE;
} else {
var css_base = STAFF_CSS_BASE;
var js_base = STAFF_JS_BASE;
}
gulp.task( "default", ['watch'] );
// CSS processing for development
gulp.task('css', function() {
return gulp.src( css_base + "/src/**/*.scss" )
.pipe(sourcemaps.init())
.pipe(sass( sassOptions ).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest( css_base ));
});
// CSS processing for production
gulp.task('build', function() {
return gulp.src( css_base + "/src/**/*.scss" )
.pipe(sass( sassOptions ).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(cssnano({ zindex: false }))
.pipe(gulp.dest( css_base ));
});
gulp.task('watch', function(){
gulp.watch( css_base + "/src/**/*.scss", ['css'] );
});