-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
123 lines (109 loc) · 3.12 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
var gulp = require("gulp"),
browserSync = require("browser-sync"),
$ = require("gulp-load-plugins")({ lazy: true }),
wait = require("gulp-wait"),
plumber = require("gulp-plumber"),
svgSprite = require("gulp-svg-sprites"),
babel = require("gulp-babel"),
uglify = require("gulp-uglify"),
pump = require("pump");
gulp.task( 'styles', function () {
return gulp
.src("./src/sass/**/*.scss")
.pipe(wait(1000))
.pipe(plumber())
.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(plumber())
// .pipe(uglify())
.pipe(gulp.dest("public/js/vendor"));
});
gulp.task( 'scripts', function () {
return gulp
.src(["./src/js/!(vendor)**/!(app)*.js", "./src/js/scripts/*.js"])
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe($.concat("app.js"))
.pipe(gulp.dest("src/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('sprites', function () {
return gulp
.src("src/icons/*.svg")
.pipe(svgSprite({mode:"symbols"})) //You'll get an SVG file and a preview file showing how to use it
.pipe(gulp.dest("public/icons")) // Write the sprite-sheet + CSS + Preview
});
<<<<<<< HEAD
gulp.task( 'html', function () {
return gulp
.src("./src/**/*.php")
.pipe(wait(1000))
.pipe(plumber())
.pipe(gulp.dest("public/"));
} );
=======
>>>>>>> 61b72e3f24234bc8e9146633c822f9b5b6e9c2d4
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
<<<<<<< HEAD
gulp.watch( 'src/**/*.php', ['html', browserSync.reload] );
gulp.watch( "public/*.php" ).on( 'change', browserSync.reload );
=======
gulp.watch( "*.php" ).on( 'change', browserSync.reload );
>>>>>>> 61b72e3f24234bc8e9146633c822f9b5b6e9c2d4
// 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',
'browser-sync',
'watch'
);
} );