This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
97 lines (81 loc) · 2.7 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
require('es6-promise').polyfill()
var gulp = require('gulp');
var nunjucksRender = require('gulp-nunjucks-render');
var htmlmin = require('gulp-htmlmin');
var postcss = require('gulp-postcss');
var sass = require('gulp-sass');
var csswring = require('csswring');
var autoprefixer = require('autoprefixer');
var notify = require('gulp-notify');
var plumber = require('gulp-plumber');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var config = {
bootstrapDir: './bower_components/bootstrap-sass',
bootstrapJsDir: './bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
jqueryDir: './bower_components/jquery/dist/jquery.js',
publicDir: './app'
};
var plumberErrorHandler = { errorHandler: notify.onError({
title: 'Gulp',
message: 'Error: <%= error.message %>'
})
};
gulp.task('css', function() {
var processors = [
csswring,
autoprefixer({browsers:['last 2 version']})
];
return gulp.src('./src/css/main.scss')
.pipe(plumber(plumberErrorHandler))
.pipe(sass({
includePaths: [config.bootstrapDir + '/assets/stylesheets'],
}))
.pipe(postcss(processors))
.pipe(gulp.dest(config.publicDir + '/css'));
});
gulp.task('fonts', function() {
return gulp.src(config.bootstrapDir + '/assets/fonts/**/*')
.pipe(gulp.dest(config.publicDir + '/fonts'));
});
gulp.task('js',function(){
return gulp.src([config.jqueryDir,config.bootstrapJsDir,'./src/js/**/*.js'])
.pipe(plumber(plumberErrorHandler))
// .pipe(jshint())
.pipe( jshint.reporter( 'fail' ))
.pipe(concat('concat.js'))
.pipe(gulp.dest('./src/concat'))
.pipe(rename('main.js'))
.pipe(uglify())
.pipe(gulp.dest(config.publicDir+'/js'));
})
gulp.task('ipau', function(){
return gulp.src('./src/pages/**/*.+(html|ipau)')
// render template
.pipe(nunjucksRender({
path:['./src/templates']
}))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('app'))
});
gulp.task('watch',function(){
gulp.watch('./src/css/*.scss',['css']);
gulp.watch('./src/js/**/*.js',['js']);
gulp.watch('./src/pages/**/*.+(html|ipau)',['ipau']);
gulp.watch('./src/templates/**/*.+(html|ipau)',['ipau']);
gulp.watch(['./src/pages/**/*.+(html|ipau)','./src/templates/**/*.+(html|ipau)']).on('change', reload);;
})
gulp.task('serve',['css','fonts','js','ipau','watch'],function(){
browserSync.init({
open: true,
port: 8080,
server: {
baseDir: "./app"
}
});
})
gulp.task('default', ['serve']);