-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (66 loc) · 2.06 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const del = require('del');
const nodemon = require('gulp-nodemon');
const cleanCSS = require('gulp-clean-css');
const plumber = require('gulp-plumber');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const runsequence = require('run-sequence');
const browserSync = require('browser-sync').create();
const env = require('./config/env');
gulp.task('clean', () => {
return del('public');
});
gulp.task('js', () => {
return gulp.src('src/js/**/*.js')
.pipe(plumber())
.pipe(babel({ presets: ['es2015'] }))
// .pipe(uglify())
.pipe(gulp.dest('public/js'));
});
gulp.task('vendor-js', () => {
return gulp.src([
'node_modules/vue/dist/vue.js',
'src/vendor/js/*.js'
])
.pipe(gulp.dest('public/js'));
});
gulp.task('css', () => {
return gulp.src('src/css/**/*.css')
.pipe(gulp.dest('public/styles'))
.pipe(browserSync.stream());
});
gulp.task('images', () => {
return gulp.src('src/images/**/*.{png,jpg,jpeg,gif,ico}')
.pipe(gulp.dest('public/images'))
.pipe(browserSync.stream());
});
gulp.task('sass', () => {
return gulp.src('src/sass/**/*.scss')
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(gulp.dest('public/styles'));
});
gulp.task('serve', ['sass', 'js'], () => {
browserSync.init({
proxy: 'http://localhost:3000',
port: 8000,
files: ['public/**/*.*'],
reloadDelay: 500,
notify: false,
open: false
});
return nodemon({ script: 'index.js'})
.on('start', () => browserSync.reload());
});
gulp.task('default', ['sass', 'css', 'images', 'vendor-js', 'js', 'serve'], () => {
gulp.watch('src/sass/**/*.scss', ['sass']);
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('src/images/**/*.{png,jpg,jpeg,gif,ico}', ['images']);
gulp.watch('views/**/*.ejs', browserSync.reload);
});
gulp.task('build', cb => {
runsequence('clean', ['css', 'sass', 'js', 'vendor-js', 'images'], cb);
});