-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
63 lines (57 loc) · 1.36 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
const gulp = require('gulp')
const uglify = require('gulp-uglify')
const autoprefixer = require('gulp-autoprefixer')
const clean = require('gulp-clean-css')
const del = require('del')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const paths = {
src: {
all: './src/*.*',
js: "./src/hes-gallery.js",
css: "./src/hes-gallery.css"
},
dist: './dist'
}
gulp.task('build', ['clean'], () => {
// CSS
gulp.src(paths.src.css)
.pipe(autoprefixer())
.pipe(gulp.dest(paths.dist))
.pipe(clean())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.dist))
// JavaScript
gulp.src(paths.src.js)
.pipe(babel({
presets: [['env', {
modules: false
}]],
}))
.on('error', function(err) {
console.error('[Compilation Error]')
console.log('error Babel: ' + err.message + '\n')
console.log(err.codeFrame)
this.emit('end')
})
.pipe(gulp.dest(paths.dist))
.pipe(uglify({
output: {
comments: /^!|@preserve|@license|@cc_on/i
}
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.dist))
})
gulp.task('watch', ['build'], () => {
gulp.watch(paths.src.css, ['build'])
gulp.watch(paths.src.js, ['build'])
})
gulp.task('clean', () => {
return del([paths.dist]);
})
gulp.task('default', ['build'])