-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (65 loc) · 1.66 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
const gulp = require('gulp');
var browserSync = require('browser-sync').create();
var webpack = require('webpack-stream');
const eslint = require('gulp-eslint');
const sass = require('gulp-sass');
const babel = require('gulp-babel');
const del = require('del');
const uglify = require('gulp-uglify');
var paths = {
scripts: './app/*.js',
images: './app/assets/*',
sass: './app/*.scss'
};
gulp.task('lint', function () {
return gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('scripts', ['lint'] , function() {
return gulp.src(paths.scripts)
.pipe(webpack(
{output: {
filename: 'index.js',
}}
))
.pipe(babel({
"presets": [
["env", { targets: { node: true } }],
]
}))
.pipe(uglify())
.pipe(gulp.dest('docs/js'));
});
gulp.task('images', function() {
return gulp.src(paths.images)
.pipe(gulp.dest('docs/assets'));
});
gulp.task('sass', function () {
return gulp.src(paths.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('docs/css'))
});
gulp.task('clean', function() {
del('docs/css');
del('docs/js');
del('docs/assets');
});
//Rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
gulp.watch(paths.sass, ['sass']);
});
gulp.task('serve', ['watch'], () => {
browserSync.init({
port : 8000,
browser: "google chrome",
open: true,
reloadOnRestart : true,
online : true,
server: "./docs"
});
});
gulp.task('default', ['clean', 'scripts', 'images', 'sass']);