This repository has been archived by the owner on Feb 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·83 lines (68 loc) · 2.07 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 browserSync = require('browser-sync').create(),
reloadBrowser = browserSync.reload
const sass = require('gulp-sass')
const plumber = require('gulp-plumber'),
clean = require('gulp-clean'),
minifyImage = require('gulp-imagemin'),
rename = require('gulp-rename')
const autoPrefixer = require('gulp-autoprefixer'),
minifyCSS = require('gulp-cssnano')
const babel = require('gulp-babel'),
minifyJS = require('gulp-uglify')
let assetsDir = './src'
let distDir = './dist'
gulp.task('ppCSS', () =>
gulp.src(`${assetsDir}/css/style.scss`)
.pipe(plumber())
.pipe(sass())
.pipe(autoPrefixer())
.pipe(rename('compiled.css'))
.pipe(gulp.dest(`${distDir}/css`))
.pipe(minifyCSS({
zindex: false
}))
.pipe(rename('style.min.css'))
.pipe(gulp.dest(`${distDir}/css`))
.pipe(browserSync.stream())
)
gulp.task('ppJS', () =>
gulp.src(`${assetsDir}/js/main.js`)
.pipe(plumber())
.pipe(babel({
presets: ['es2015']
}))
.pipe(rename('compiled.js'))
.pipe(gulp.dest(`${distDir}/js`))
.pipe(minifyJS())
.pipe(rename('main.min.js'))
.pipe(gulp.dest(`${distDir}/js`))
.pipe(browserSync.stream())
)
gulp.task('watch', ['ppCSS', 'ppJS'], () => {
browserSync.init({
server: "./",
port: 4000,
})
gulp.watch(`./**/*.html`, reloadBrowser)
gulp.watch(`${assetsDir}/css/style.scss`, ['ppCSS'])
gulp.watch(`${assetsDir}/js/main.js`, ['ppJS'])
})
gulp.task('buildAssets', () => {
gulp.src(`${assetsDir}/img/**/*`, {
base: `${assetsDir}/img/`
})
.pipe(minifyImage())
.pipe(gulp.dest(`${distDir}/img`))
gulp.src(`${assetsDir}/fonts/**/*`)
.pipe(gulp.dest(`${distDir}/fonts`))
gulp.src(`${assetsDir}/json/**/*`)
.pipe(gulp.dest(`${distDir}/json`))
})
gulp.task('cleanDist', () => {
gulp.src(`${distDir}`)
.pipe(clean())
})
gulp.task('buildDist', ['ppCSS', 'ppJS'], () => {
console.log('Done')
})