-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
46 lines (35 loc) · 1.1 KB
/
gulpfile.babel.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
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const cleancss = require('gulp-clean-css');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const paths = {
javascripts: [
'static/javascripts/**/*.js',
'!static/javascripts/**/*.min.js'
],
stylesheets: [
'static/stylesheets/**/*.css',
'!static/stylesheets/**/*.min.css'
]
};
const buildDirectory = 'static';
gulp.task('buildcss', _ => {
return gulp.src(paths.stylesheets, { base: 'static' })
.pipe(autoprefixer({ browsers: ['last 2 versions'] }))
.pipe(cleancss())
.pipe(rename(path => path.extname = '.min.css'))
.pipe(gulp.dest(buildDirectory));
});
gulp.task('buildjs', _ => {
return gulp.src(paths.javascripts, { base: 'static' })
.pipe(uglify())
.pipe(rename(path => path.extname = '.min.js'))
.pipe(gulp.dest(buildDirectory));
});
gulp.task('build', ['buildcss', 'buildjs']);
gulp.task('watch', _ => {
gulp.watch(paths.stylesheets, ['buildcss']);
gulp.watch(paths.javascripts, ['buildjs']);
});
gulp.task('default', ['build', 'watch']);