-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
60 lines (49 loc) · 1.48 KB
/
gulpfile.js
File metadata and controls
60 lines (49 loc) · 1.48 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
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var webpack = require('webpack-stream');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var del = require('del');
var webpackConfig = require('./webpack.config.js');
var paths = {
scripts: 'src/app.js',
images: 'src/img/**',
css: 'src/css/*.css',
html: 'src/views/**'
};
gulp.task('clean', function() {
return del(['dist/*', '!dist/libs', '!dist/img']);
});
gulp.task('clean-images', function() {
return del(['dist/img']);
});
gulp.task('scripts', ['clean'], function() {
return gulp.src(paths.scripts)
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('dist/js'));
});
gulp.task('html', ['clean'], function() {
return gulp.src(paths.html)
.pipe(gulp.dest('dist/views'));
});
gulp.task('css', ['clean'], function(){
return gulp.src(paths.css)
.pipe(gulp.dest('dist/css/'))
.pipe(minifyCss())
.pipe(rename({extname: '.min.css'}))
.pipe(gulp.dest('dist/css/'));
});
gulp.task('images', ['clean-images'], function() {
return gulp.src(paths.images)
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest('dist/img'));
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
gulp.watch(paths.css, ['css']);
gulp.watch(paths.html, ['html']);
});
gulp.task('build', ['scripts', 'css', 'html']);
gulp.task('build-images', ['build', 'images']);
gulp.task('default', ['watch', 'build-images']);