-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
54 lines (48 loc) · 1.32 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
const gulp = require('gulp')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
// const concat = require('gulp-concat')
// const babel = require('gulp-babel')
// const watch = require('gulp-watch')
const browserSync = require('browser-sync')
const reload = browserSync.reload
const shell = require('gulp-shell')
gulp.task('default', ['styles', 'webpack', 'browser-sync'], () => {
gulp.watch('./assets/sass/**/*', ['styles'])
gulp.watch('./assets/js/**/*', ['webpack'])
})
gulp.task('styles', () => {
gulp.src('assets/sass/**/*.scss')
.pipe(
sass({
outputStyle: 'compressed'
})
.on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream())
})
gulp.task('browser-sync', ['styles'], function () {
browserSync.init({
proxy: {
target: 'localhost:3000', // can be [virtual host, sub-directory, localhost with port]
ws: true // enables websockets
},
serveStatic: ['.', './public']
})
})
gulp.task('webpack', () => {
return gulp.src('*.js', {read: false})
.pipe(shell([
'webpack'
]))
.pipe(browserSync.stream())
})
// gulp.task('webpack', shell.task([
// 'webpack'
// ]))
// gulp.task('server', shell.task([
// 'yarn run server'
// ]))