Repository navigation
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
64 lines (59 loc) · 2.01 KB
/
Copy pathgulpfile.babel.js
File metadata and controls
64 lines (59 loc) · 2.01 KB
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
import gulp from 'gulp';
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import concat from 'gulp-concat';
import sourcemaps from 'gulp-sourcemaps';
import notifier from 'node-notifier';
import gutil from 'gulp-util';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
const browserSync = require('browser-sync').create();
gulp.task('js', () => {
return gulp.src([
'./js/**/*.js'
])
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('potato.min.js'))
.pipe(babel({presets: ['es2015'], compact: false, minified: true}).on('error', function(err) {
gutil.log(gutil.colors.bold.red('Babel compile error'), err.message);
notifier.notify({title: 'Babel compile error',message: err.message});
this.emit('end');
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./js/'))
.pipe(browserSync.reload({stream: true}));
})
gulp.task('sass', () => {
return gulp.src([
'./stylesheets/sass/**/*.scss',
'!./stylesheets/sass/**/_*.scss'
])
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('potato.css'))
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('./stylesheets/css/'))
.pipe(sass({outputStyle: 'compressed'}).on('error', function(err) {
gutil.log(gutil.colors.bold.red('Sass compile error'), err.message);
notifier.notify({title: 'Sass compile error',message: err.message});
this.emit('end');
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./stylesheets/css/'))
.pipe(browserSync.stream());
})
gulp.task('watch', () => {
// gulp.watch(['./stylesheets/sass/**/*.scss', '!./stylesheets/sass/**/_*.scss'], ['sass'])
gulp.watch(['./js/**/*.js'], ['js'])
gulp.watch(['./examples/*.html']).on('change', browserSync.reload);
})
gulp.task('browserSync', () => {
browserSync.init({
server: {
baseDir: "./",
index: "/examples/index.html"
}
});
});
// gulp.task('default', ['js', 'sass', 'browserSync', 'watch']);
gulp.task('default', ['js', 'browserSync', 'watch']);