-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·88 lines (80 loc) · 2.08 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
// VARIABLES
// const gulp = require('gulp');
const { watch, series, src, dest } = require('gulp');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();
const zip = require('gulp-zip');
// FILES
function getFiles() {
return src('node_modules/normalize.css/normalize.css')
.pipe(dest('css/'));
}
// SASS
function compileSass() {
return src('css/template.scss')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(dest('css/'));
}
// CSS
function prepareCss() {
return src([
'css/normalize.css',
'css/template.css'
])
.pipe(sourcemaps.init())
.pipe(concat('style.css'))
.pipe(cleanCSS())
.pipe(sourcemaps.write())
.pipe(dest('build/'))
.pipe(browserSync.stream());
}
// JS
function uglifyJavascript() {
return src([
'js/particles.js',
'js/script.js'
])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('app.js'))
.pipe(sourcemaps.write())
.pipe(dest('build/'))
.pipe(browserSync.stream());
}
// ZIP
function zipTemplate() {
return src([
'**/*',
'!node_modules/**',
'!dist/**'
])
.pipe(zip('jd19de.zip'))
.pipe(dest('../'));
}
// SERVE
function serveSite() {
browserSync.init({
proxy: 'http://localhost/jd19de2/'
});
watch('js/**/*.js', series(uglifyJavascript, zipTemplate));
watch('css/**/*.scss', series(compileSass));
watch('css/**/*.css', series(prepareCss, zipTemplate));
watch('**/*.php', series(zipTemplate)).on('change', browserSync.reload);
}
// DEFAULT
exports.default = series(
getFiles,
compileSass,
prepareCss,
uglifyJavascript,
zipTemplate,
serveSite
);