This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
gulpfile.js
92 lines (92 loc) · 3.05 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
const gulp=require('gulp');
const browserify=require('browserify');
const babelify=require('babelify');
const concat=require('gulp-concat');
const source=require('vinyl-source-stream');
const streamify = require('gulp-streamify');
const uglify = require('gulp-uglify');
const connect=require('gulp-connect');
const imagemin = require('gulp-imagemin');
const cleanCSS = require('gulp-clean-css');
const htmlmin = require('gulp-htmlmin');
const ghPages = require('gulp-gh-pages');
const cssAssets = [
`${__dirname}/src/css/materialize.css`,
`${__dirname}/src/css/font-awesome.css`,
`${__dirname}/src/css/timelinecss.css`,
`${__dirname}/src/css/mouse.css`,
`${__dirname}/src/css/animate.css`,
`${__dirname}/src/css/styles.css`,
`${__dirname}/src/css/slick.css`,
`${__dirname}/src/css/slick-theme.css`
];
gulp.task('server',function () {
connect.server({
base:'http://localhost',
port:'8000',
root:'./dist',
livereload:true
});
});
gulp.task('js',function () {
browserify(`${__dirname}/src/js/script.js`)
.transform(babelify)
.bundle()
.pipe(source('bundle.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest(`${__dirname}/dist/js`))
.pipe(connect.reload());
});
gulp.task('css',function () {
gulp.src(cssAssets)
.pipe(concat('bundle.css'))
.pipe(cleanCSS())
.pipe(gulp.dest(`${__dirname}/dist/css`));
gulp.src(`${__dirname}/src/scss/effect.css`)
.pipe(cleanCSS())
.pipe(gulp.dest(`${__dirname}/dist/css`))
.pipe(connect.reload());
});
gulp.task('images',function () {
gulp.src(`${__dirname}/src/img/*`)
.pipe(imagemin([imagemin.optipng({optimizationLevel: 7})]))
.pipe(gulp.dest(`${__dirname}/dist/img`))
.pipe(connect.reload());
});
gulp.task('fonts',function () {
gulp.src(`${__dirname}/src/fonts/*`)
.pipe(gulp.dest(`${__dirname}/dist/fonts`))
.pipe(connect.reload());
});
gulp.task('manifest',function () {
gulp.src(`${__dirname}/src/manifest.json`)
.pipe(gulp.dest(`${__dirname}/dist`))
.pipe(connect.reload());
});
gulp.task('html',function () {
gulp.src(`${__dirname}/src/index.html`)
.pipe(htmlmin({
collapseWhitespace:true,
minifyCSS:true,
minifyJS:true,
removeComments:true
})
)
.pipe(gulp.dest(`${__dirname}/dist`))
.pipe(connect.reload());
});
gulp.task('watch',function () {
gulp.watch(`${__dirname}/src/index.html`,['html']);
gulp.watch(`${__dirname}/src/manifest.json`,['manifest']);
gulp.watch(`${__dirname}/src/css/*`,['css']);
gulp.watch(`${__dirname}/src/js/*`,['js']);
gulp.watch(`${__dirname}/src/img/*`,['images']);
});
gulp.task('deploy', function() {
return gulp.src(`${__dirname}/dist/**/*`)
.pipe(ghPages());
});
gulp.task('default',['css','js','images','fonts','html','manifest','server','watch'],function () {
console.log('Server connected at http://localhost:8000');
console.log('Watching for changes.');
});