This repository has been archived by the owner on May 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (54 loc) · 1.49 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
const autoprefixer = require('gulp-autoprefixer')
const browserify = require('browserify')
const browserSync = require('browser-sync').create()
const buffer = require('vinyl-buffer')
const gulp = require('gulp')
const imagemin = require('gulp-imagemin')
const sass = require('gulp-sass')
const source = require('vinyl-source-stream')
const uglify = require('gulp-uglify')
gulp.task('css', () => gulp.src('src/css/styles.scss')
.pipe(sass({
includePaths: [
'node_modules/normalize-scss/sass'
],
outputStyle: 'compressed'
})
.on('error', sass.logError))
.pipe(autoprefixer({
browsers: [ 'last 2 versions', 'ie >= 11' ]
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.stream())
)
gulp.task('js', () => browserify('src/js/scripts.js')
.bundle()
.on('error', function (err) {
console.error(err)
this.emit('end')
})
.pipe(source('scripts.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('js'))
.pipe(browserSync.reload({ stream: true }))
)
gulp.task('img', () => gulp.src('src/img/**')
.pipe(imagemin())
.pipe(gulp.dest('img'))
)
gulp.task('build', [ 'css', 'js', 'img' ])
gulp.task('watch', [ 'build' ], () => {
browserSync.init({ proxy: 'statamic-theme.dev', notify: false })
gulp.watch('src/css/**/*.scss', [ 'css' ])
gulp.watch('src/js/**/*.js', [ 'js' ])
gulp.watch('src/img/**', [ 'img' ])
gulp.watch([
'layouts/**/*',
'partials/**/*',
'templates/**/*'
], () => {
browserSync.reload()
})
})
gulp.task('default', [ 'watch' ])