forked from peterbaker/design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (72 loc) · 2.24 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const browserSync = require('browser-sync').create()
const cssnano = require('cssnano')
const gulp = require('gulp')
const htmlmin = require('gulp-htmlmin')
const sass = require('gulp-sass')
const postcss = require('gulp-postcss')
const jsmin = require('gulp-jsmin')
const rename = require('gulp-rename')
const json = require('./scripts/render_json')
const page = require('./scripts/render_page')
gulp.task('pages', () => (
gulp.src('assets/templates/*.html')
.pipe(page('assets/templates'))
.pipe(htmlmin({
collapseWhitespace: true,
conservativeCollapse: true,
}))
.pipe(gulp.dest('dist'))
))
gulp.task('styles', () => (
gulp.src('assets/styles/**/*.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(postcss([
cssnano()
]))
.pipe(gulp.dest('dist/styles'))
.pipe(browserSync.stream())
))
gulp.task('referenceFiles', () => {
gulp.src('assets/styles/**/*.css')
.pipe(gulp.dest('dist/styles'))
.pipe(browserSync.stream())
gulp.src('assets/js/reference/**/**/*.js')
.pipe(jsmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/js'))
})
gulp.task('scripts', () => (
gulp.src('assets/js/general.js')
.pipe(jsmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/js'))
))
gulp.task('images', () => (
gulp.src('assets/images/*')
.pipe(gulp.dest('dist/images'))
))
gulp.task('fonts', () => (
gulp.src('assets/fonts/**/*')
.pipe(gulp.dest('dist/fonts'))
))
gulp.task('json', () => (
gulp.src('assets/json/*.json')
// .pipe(json('assets/json/'))
.pipe(gulp.dest('dist/json'))
))
gulp.task('build', ['pages', 'json', 'styles', 'scripts', 'images', 'fonts', 'referenceFiles'])
gulp.task('refresh', ['pages', 'styles', 'scripts'])
gulp.task('watch', ['refresh'], () => {
gulp.watch([
'assets/pages/**/*.md',
'assets/templates/**/*.html',
], ['pages']).on('change', browserSync.reload)
gulp.watch('assets/styles/**/**/*.scss', ['styles'])
gulp.watch('assets/js/**/*.js', ['scripts'])
browserSync.init({
server: {
baseDir: 'dist',
},
open: false,
})
})