forked from dcowen91/better-fpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (65 loc) · 1.83 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
/*
* Always run task `scripts` before publishing extension
*/
'use strict'
// Dependencies
const gulp = require('gulp')
const sass = require('gulp-sass')
const concat = require('gulp-concat')
const plumber = require('gulp-plumber')
const notify = require('gulp-notify')
const babel = require('gulp-babel')
const pug = require('gulp-pug')
const webpack = require('webpack-stream')
const webpackConfig = require('./webpack.config.js')
const uglify = require('gulp-uglify')
const clean = require('gulp-clean-css')
// Error handler
function onError(err) {
notify().write(err)
this.emit('end')
}
// Sass task
gulp.task('sass', () => {
return gulp
.src('assets/sass/style.sass')
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(gulp.dest('assets/dist/chrome'))
.pipe(gulp.dest('assets/dist/firefox'))
})
gulp.task('babel', ['webpack'], () => {
return gulp
.src('./assets/dist/chrome/scripts.min.js')
.pipe(babel({
compact: false,
presets: ['es2015']
}))
.pipe(gulp.dest('./assets/dist/chrome'))
.pipe(gulp.dest('./assets/dist/firefox'))
})
gulp.task('webpack', () => {
return gulp
.src('./assets/js/scripts.js')
.pipe(plumber({errorHandler: onError}))
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('assets/dist/chrome'))
})
// Pug task
gulp.task('pug', () => {
return gulp.src('./assets/views/*.pug')
.pipe(plumber({errorHandler: onError}))
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('assets/dist/chrome'))
.pipe(gulp.dest('assets/dist/firefox'))
})
// Watch task
gulp.task('watch', () => {
gulp.watch('assets/js/**/*.js', {cwd: '.'}, ['webpack'])
gulp.watch('assets/sass/**/*.sass', {cwd: '.'}, ['sass'])
gulp.watch('assets/views/**/*.pug', {cwd: '.'}, ['pug'])
})
// Default task
gulp.task('default', ['sass', 'webpack', 'pug', 'watch'])