-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
77 lines (68 loc) · 1.82 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
var gulp = require('gulp');
plugins = require('gulp-load-plugins')(),
browserSync = require('browser-sync').create(),
del = require('del'),
manifest = require('./assets/manifest.json');
var assets = manifest.assets;
var config = manifest.config;
gulp.task('sass', function(){
return gulp.src(assets.styles)
.pipe(plugins.plumber({
errorHandler: plugins.notify.onError("Error: <%= error.message %>")
}))
.pipe(plugins.sass()) // Using gulp-sass
.pipe(plugins.autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(plugins.cssnano())
.pipe(plugins.size())
.pipe(gulp.dest('dist/styles'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('scripts', function(){
return gulp.src(assets.scripts)
.pipe(plugins.concat('main.js'))
.pipe(plugins.minify({
ext:{
min:'.js'
},
noSource: true
}))
.pipe(plugins.jshint())
.pipe(plugins.plumber({
errorHandler: plugins.notify.onError("Error: <%= error.message %>")
}))
.pipe(gulp.dest('dist/scripts'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('fonts', function(){
return gulp.src([
'./assets/fonts/*'
])
.pipe(gulp.dest('dist/fonts'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('clean', function () {
return del([
'dist',
]);
});
gulp.task('watch', ['sass', 'scripts', 'fonts'], function() {
browserSync.init({
proxy: "http://" + config.devUrl,
host: config.devUrl,
files: "*.php"
});
gulp.watch('./assets/styles/*.scss', ['sass']);
gulp.watch('./assets/styles/**/*.scss', ['sass']);
gulp.watch('./assets/scripts/*.js', ['scripts']);
gulp.watch('./*.php').on('change', browserSync.reload);
});
gulp.task('default', ['sass', 'scripts', 'fonts']);