-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·75 lines (61 loc) · 2.2 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create(),
concat = require('gulp-concat');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
var siteroot = "./";
gulp.task('sass', function() {
return gulp.src(siteroot + 'sass/**/*.scss')
.pipe(sass().on('error', sass.logError)) // Using gulp-sass + error handling
.pipe(autoprefixer('last 2 versions'))
//.pipe(minify())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('js', function() {
// set concat order to dependencies first then all other remaining files -
//return gulp.src([siteroot + 'js/bacon.js', siteroot + 'js/eggs.js', siteroot + 'js/*.js' ])
return gulp.src(siteroot + 'js/**/*.js')
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/js'));
});
//image min - combines gifsicle, jpegtran, optipng, svgo
gulp.task('imgcomp', () => {
return gulp.src(siteroot + 'img/**/*')
.pipe(imagemin({
optimizationLevel: 4,
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
use: [pngquant()]
}))
.pipe(gulp.dest('dist/img'));
});
// Static server
gulp.task('browserSync', function() {
browserSync.init({
server: {
//baseDir: ["app", "dist"] //location of site
baseDir: "./" //location of site
}
});
});
// dynamic site
// gulp.task('browserSync', function() {
// browserSync.init({
// proxy: "http://localhost:8888/atomic-site-boilerplate/app" // Server link
// });
// });
//below will watch files once the browsersync task is completed
gulp.task('watch', ['browserSync'], function() {
gulp.watch(siteroot + 'sass/**/*.scss', ['sass']);
gulp.watch(siteroot + '**/*.html', browserSync.reload);
gulp.watch(siteroot + '**/*.php', browserSync.reload);
gulp.watch(siteroot + 'js/**/*.js', browserSync.reload);
// Other watchers
})
//spin up browsersync server, then run watch tasks
gulp.task('default', ['sass', 'js', 'browserSync', 'watch']);