-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (74 loc) · 2.14 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
const gulp = require('gulp')
const jade = require('gulp-jade')
const sass = require('gulp-sass')
const watch = require('gulp-watch')
const concat = require('gulp-concat')
const imagemin = require('gulp-imagemin')
const clean = require('gulp-clean')
const minifyCss = require('gulp-cssnano')
const postcss = require('gulp-postcss')
const autoprefixer = require('autoprefixer')
// var webpack = require('gulp-webpack');
// var webpackConfig = require('./webpack.config.babel');
gulp.task('sass', () => {
// gulp.src('./src/routes/**/*.sass')
// .pipe(sass().on('error', sass.logError))
// .pipe(postcss([autoprefixer({ browsers: ['last 2 versions'] })]))
// .pipe(minifyCss({ zindex: false }))
// .pipe(gulp.dest('dist/'))
gulp.src(['./src/public/style/main.sass', './src/components/**/*.sass'])
.pipe(concat('min.sass'))
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
autoprefixer({
browsers: ['last 2 versions', 'last 10 iOS versions'] ,
add: true,
remove: true
})
]))
.pipe(minifyCss({ zindex: false }))
.pipe(gulp.dest('dist/style'))
gulp.src(['./src/public/style/main.sass', './src/components/**/*.sass'])
.pipe(concat('min.sass'))
.pipe(gulp.dest('dist/style'))
})
gulp.task('html', () => {
gulp.src('./src/views/*.jade')
.pipe(jade({ pretty: true }))
.pipe(gulp.dest('./dist/views/'))
})
gulp.task('image', () => {
gulp.src('./dist/img/*', { read: false })
.pipe(clean())
gulp.src('./src/public/img/**')
.pipe(watch('./src/public/img/**'))
.pipe(
imagemin({
optimizationLevel: 5,
progressive: true
})
)
.pipe(gulp.dest('./dist/img/'))
})
gulp.task('sass:watch', () => {
watch('./src/**/*.sass', () => {
gulp.start('sass')
})
})
gulp.task('html:watch', () => {
watch('./src/**/*.jade', () => {
gulp.start('html')
})
})
gulp.task('image:watch', () => {
watch('./src/public/img/**', () => {
gulp.start('image')
})
})
// gulp.task('webpack', function() {
// return gulp.src('./src')
// .pipe(webpack(webpackConfig))
// .pipe(gulp.dest('./dist'))
// })
gulp.task('default', ['html', 'sass', 'image', 'html:watch', 'sass:watch', 'image:watch'], () => {
})