-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (76 loc) · 2.21 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
// include the required packages.
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var plumber = require('gulp-plumber');
var cssmin = require('gulp-cssmin');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var mqpacker = require('css-mqpacker');
var imagemin = require('gulp-imagemin');
var babel = require('gulp-babel');
var reload = browserSync.reload;
gulp.task('stylus', function () {
return gulp.src('./src/styl/main.styl')
.pipe(plumber())
.pipe(stylus({
paths : ['./assets/img'],
url : 'embedurl',
'include css': true,
}))
.pipe(postcss([
autoprefixer,
mqpacker
]))
.pipe(rename({ suffix: '.min' }))
.pipe(cssmin())
.pipe(gulp.dest('./dist/css'))
.pipe(reload({stream: true}));
});
gulp.task('javascript', function () {
return gulp.src([
'./src/js/**/*.js',
])
.pipe(plumber())
.pipe(babel({
presets: ['babel-preset-es2015'],
ignore: 'lib/*.js'
}))
.pipe(concat('scripts.js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('./dist/js'))
.pipe(reload({stream: true}));
});
gulp.task('html', function () {
var options = {
compress: false
};
return gulp.src('./src/**/*.html')
.pipe(plumber())
.pipe(gulp.dest('./dist'))
.pipe(reload({stream: true}));
});
gulp.task('images', function () {
return gulp.src('src/img/**/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}]
}))
.pipe(gulp.dest('./dist/img'));
});
// Default
gulp.task('default', function () {
browserSync({
server: "./dist",
notify: false,
ghostmode: false,
});
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/styl/**/*.styl', ['stylus']);
gulp.watch('src/img/**/*', ['images']);
gulp.watch('src/js/*.js', ['javascript']);
});