-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·95 lines (86 loc) · 2.34 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·95 lines (86 loc) · 2.34 KB
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
var
gulp = require( 'gulp' ),
browserSync = require( 'browser-sync' ),
$ = require( 'gulp-load-plugins' )( {lazy: true} );
gulp.task( 'styles', function () {
return gulp
.src( './src/sass/**/*.scss' )
.pipe( $.sass().on( 'error', $.sass.logError ) )
.pipe( $.autoprefixer( 'last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4' ) )
.pipe( $.cleanCss() )
.pipe( gulp.dest( 'public/css' ) )
.pipe( browserSync.reload( {stream: true} ) );
} );
gulp.task('vendorScripts', function() {
gulp.src('./src/js/vendor/**/*.js')
.pipe(gulp.dest('public/js/vendor'));
});
gulp.task( 'scripts', function () {
return gulp
.src( [
'./src/js/!(vendor)**/!(app)*.js',
'./src/js/app.js'
] )
.pipe( $.plumber() )
.pipe( $.babel() )
.pipe( $.concat( 'app.js' ) )
.pipe( $.uglify() )
.pipe( gulp.dest( 'public/js' ) )
.pipe( browserSync.reload( {stream: true} ) );
} );
// Optimizes the images that exists
gulp.task( 'images', function () {
return gulp
.src( 'src/images/**' )
.pipe( $.changed( 'images' ) )
.pipe( $.imagemin( {
// Lossless conversion to progressive JPGs
progressive: true,
// Interlace GIFs for progressive rendering
interlaced: true
} ) )
.pipe( gulp.dest( 'public/images' ) )
.pipe( $.size( {title: 'images'} ) );
} );
gulp.task( 'html', function () {
return gulp
.src( './src/**/*.html' )
.pipe( gulp.dest( 'public/' ) )
} );
gulp.task( 'browser-sync', ['styles', 'scripts'], function () {
browserSync( {
server: {
baseDir: "./public/",
injectChanges: true // this is new
}
} );
} );
gulp.task( 'deploy', function () {
return gulp
.src( './public/**/*' )
.pipe( ghPages() );
} );
gulp.task( 'watch', function () {
// Watch .html files
gulp.watch( 'src/**/*.html', ['html', browserSync.reload] );
gulp.watch( "public/*.html" ).on( 'change', browserSync.reload );
// Watch .sass files
gulp.watch( 'src/sass/**/*.scss', ['styles', browserSync.reload] );
// Watch .js files
gulp.watch( 'src/js/*.js', ['scripts', browserSync.reload] );
// Watch .js files
gulp.watch( 'src/js/vendor/*', ['vendorScripts', browserSync.reload] );
// Watch image files
gulp.watch( 'src/images/**/*', ['images', browserSync.reload] );
} );
gulp.task( 'default', function () {
gulp.start(
'styles',
'vendorScripts',
'scripts',
'images',
'html',
'browser-sync',
'watch'
);
} );