-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
executable file
·51 lines (45 loc) · 1.43 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
var gulp = require('gulp')
var autoprefixer = require('gulp-autoprefixer')
var concat = require('gulp-concat')
var cssnano = require('gulp-cssnano')
var filter = require('gulp-filter')
var newer = require('gulp-newer')
var notify = require('gulp-notify')
var sass = require('gulp-sass')
var sassGlob = require('gulp-sass-glob')
var uglify = require('gulp-uglify')
var wrap = require('gulp-wrap')
var paths = {
scriptSrc: 'js/**/*.js',
scriptDest: 'docs/assets',
scriptWatch: 'js/**/*.js',
styleSrc: 'scss/*.scss',
styleDest: 'docs/assets',
styleWatch: 'scss/**/*.scss',
}
gulp.task('scripts', function() {
gulp.src(paths.scriptWatch)
.pipe(newer(paths.scriptDest + '/*.js'))
.pipe(filter(paths.scriptSrc))
.pipe(concat('script.js'))
.pipe(wrap(';(function () { <%=contents%> })()'))
.pipe(uglify())
.on('error', notify.onError({title: 'Uglify Error', message: '<%=error%>'}))
.pipe(gulp.dest(paths.scriptDest))
})
gulp.task('styles', function() {
gulp.src(paths.styleWatch)
.pipe(newer(paths.styleDest + '/*.css'))
.pipe(filter(paths.styleSrc))
.pipe(sassGlob())
.pipe(sass())
.on('error', notify.onError({title: 'Sass Error', message: '<%=error%>'}))
.pipe(cssnano())
.pipe(autoprefixer())
.pipe(gulp.dest(paths.styleDest))
})
gulp.task('compile', ['scripts', 'styles'])
gulp.task('default', ['scripts', 'styles'], function() {
gulp.watch(paths.scriptWatch, ['scripts'])
gulp.watch(paths.styleWatch, ['styles'])
})