-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
82 lines (71 loc) · 2.26 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
const gulp = require('gulp');
const stylus = require('gulp-stylus');
const concat = require('gulp-concat');
const connect = require('gulp-connect');
const plumber = require('gulp-plumber');
const watch = require('gulp-watch');
const livereload = require('gulp-livereload');
const browserSync = require('browser-sync');
const imagemin = require('gulp-imagemin');
const jeet = require('jeet');
const rupture = require('rupture');
const stylint = require('gulp-stylint');
const files = ['index.html', './build/css/main.css', './build/js/main.js'];
//Browser Sync
gulp.task('browser-sync', () => {
browserSync.init(files, {
server: {
baseDir: './'
}
});
});
//Stylus Task
gulp.task( 'stylus', () => {
gulp.src( './source/styl/main.styl' )
.pipe(stylus({ compress: true }) )
.pipe(concat('main.css'))
.pipe(plumber())
.pipe(stylus({
use:[jeet(),rupture()],
compress: true
}))
.pipe(browserSync.reload({stream:true}))
.pipe( gulp.dest( './build/css' ) );
});
//Stylus lint Task
gulp.task('gulp-stylint', () => {
gulp.src('./source/styl/**/*.styl')
.pipe(stylint({config: '.stylintrc'}))
.pipe(stylint.reporter())
});
//Concat Javascript Task
gulp.task('scripts', () => {
gulp.src('./source/js/*.js')
.pipe(concat('main.js'))
.pipe(gulp.dest('./build/js'));
});
//Brower reload Task
gulp.task( 'files', () => {
gulp.src( files ).pipe( connect.reload() );
});
//Minify img
gulp.task('imagemin', () => {
return gulp.src('source/img/**/*')
.pipe(plumber())
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('build/img/'));
});
//Watch Task
gulp.task( 'watch', () => {
gulp.watch( files, [ 'files' ]);
gulp.watch('./source/styl/**/*.styl', ['stylus']);
gulp.watch('./source/js/*.js', ['scripts']);
gulp.watch('src/img/**/*.{jpg,png,gif}', ['imagemin']);
gulp.watch('./source/styl/**/*.styl', ['gulp-stylint']);
});
//Connect Task
gulp.task( 'connect', () => {
connect.server({ livereload: true });
});
//Default Task
gulp.task( 'default', [ 'stylus', 'gulp-stylint', 'files', 'watch', 'connect', 'scripts', 'browser-sync', 'imagemin' ]);