forked from fi3ework/hexo-theme-archer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (59 loc) · 1.51 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
const gulp = require('gulp'),
webpack = require('webpack'),
sass = require('gulp-sass'),
browserSync = require('browser-sync').create()
/* ========== develop ========== */
// webpack
gulp.task('webpack', function (cb) {
webpack(require('./webpack.config.js'), function (err) {
if (err) return cb(err)
cb()
})
})
// sass
gulp.task('sass', function () {
return gulp.src(['./src/scss/style.scss', './src/scss/mobile.scss'])
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(gulp.dest('./source/css/'))
})
// browser-sync
// watch js
gulp.task('reload-js', ['webpack'], function (done) {
browserSync.reload()
done()
})
// watch sass
gulp.task('reload-css', ['sass'], function (done) {
browserSync.reload()
done()
})
// watch layout
gulp.task('reload-layout', function (done) {
browserSync.reload()
done()
})
// watch _config
gulp.task('reload-config', function (done) {
browserSync.reload()
done()
})
gulp.task('dev', ['webpack', 'sass'], function () {
browserSync.init({
proxy: 'localhost:4000'
})
gulp.watch(['./src/js/**/*.js'], ['reload-js'])
gulp.watch(['./src/scss/**/*.scss'], ['reload-css'])
gulp.watch(['./layout/**/*.ejs'], ['reload-layout'])
gulp.watch(['./_config.yml'], ['reload-config'])
})
/* ========== bulid ========== */
// webpack-prod
gulp.task('webpack-prod', function (cb) {
webpack(require('./webpack.prod.js'), function (err) {
if (err) return cb(err)
cb()
})
})
gulp.task('build', ['sass', 'webpack-prod'])