-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
144 lines (105 loc) · 3.44 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var hbsAll = require('gulp-handlebars-all');
var handlebars = require('handlebars');
var rename = require('gulp-rename');
//var waypoints = require('waypoints');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require("gulp-uglify");
//var path = require('path');
//var autoprefixer = require('gulp-autoprefixer');
//var htmlmin = require('gulp-html-minifier');
//const imagemin = require('gulp-imagemin');
//var reporter = require('gulp-less-reporter');
var webserver = require('gulp-webserver');
var watch = require('gulp-watch');
//handlebars.registerPartial('header', '{{header}}'),
//handlebars.registerPartial('details', '{{details}}'),
//handlebars.registerPartial('info', '{{info}}'),
//handlebars.registerPartial('prefooter','{{prefooter}}'),
//handlebars.registerPartial('footer', '{{footer}}')
gulp.task('default', function () {
options = {
partialsDirectory : ['./templates/partials/**']
}
return gulp.src('templates/index.hbs')
.pipe(gulpHandlebars( options))
.pipe(rename('index.html'))
.pipe(gulp.dest('../'));
});
gulp.task('hbsToHTML', function() {
gulp.src('templates/*.hbs')
.pipe(hbsAll('html', {
context: {foo: 'bar'},
partials: ['templates/partials/*.hbs'],
}))
.pipe(rename('index.html'))
//.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./build/'));
});
// /*gulp.task('less', function () {
// return gulp.src('./less/**/*.less')
// .pipe(less({
// paths: [ path.join(__dirname, 'less', 'includes') ]
// }))
// .pipe(gulp.dest('./css'));
// });*/
// task
gulp.task('minify-js', function () {
gulp.src('./javascript/custom/*.js') // path to your files
.pipe(uglify())
.pipe(gulp.dest('./build/js'));
});
var input = './sass/*.scss';
var output = './build/css';
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: "./build/"
});
gulp.watch(input, ['sass']);
gulp.watch("build/*.html").on('change', browserSync.reload);
});
gulp.task('sass', function () {
return gulp
// Find all `.scss` files from the `stylesheets/` folder
.src(input)
// Run Sass on those files
.pipe(sass())
// Write the resulting CSS in the output folder
.pipe(gulp.dest(output))
.pipe(browserSync.stream());
});
// gulp.task('prefix', function () {
// return gulp.src('css/main.css')
// .pipe(autoprefixer({
// browsers: ['last 2 versions'],
// cascade: false
// }))
// .pipe(gulp.dest('./css'));
// });
// gulp.task('reporter', function() {
// gulp.src('less/main.less').
// pipe(less()).on('error', reporter);
// });
// gulp.task('image', () =>
// gulp.src('templates/partials/**/*.png')
// .pipe(imagemin())
// .pipe(gulp.dest('img'))
// );
gulp.task('server', function() {
gulp.src('./build/')
.pipe(webserver({
port: 3000,
directoryListing: false,
open: true
}));
});
gulp.task('watch', [ 'default', 'hbsToHTML', 'sass'], function () {
//console.log('hello world');
gulp.watch('templates/partials/*.hbs', ['default']);
gulp.watch('templates/*.hbs', ['hbsToHTML']);
gulp.watch('./sass/*.scss', ['sass']);
});
gulp.task('default', ['hbsToHTML', 'minify-js', /*'less', 'prefix', 'reporter', 'image',*/ 'sass', 'serve']);