-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
120 lines (102 loc) · 2.59 KB
/
gulpfile.babel.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
import gulp from 'gulp';
import sass from 'gulp-sass';
import autoprefixer from 'gulp-autoprefixer';
import source from 'vinyl-source-stream';
import buffer from 'vinyl-buffer';
import browserify from 'browserify';
import uglify from 'gulp-uglify';
import gutil from 'gulp-util';
import del from 'del';
import sourcemaps from 'gulp-sourcemaps';
import runSequenceBase from 'run-sequence';
const runSequence = runSequenceBase.use(gulp);
const AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
const dirs = {
src: 'src',
dest: 'build'
};
const sassPaths = {
src: `${dirs.src}/css/main.scss`,
dest: `${dirs.dest}/css/`
};
gulp.task('sass', () => {
return gulp.src(sassPaths.src)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass.sync().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(sassPaths.dest));
});
const cssPaths = {
src: `${dirs.src}/css/*.css`,
dest: `${dirs.dest}/css/`
};
gulp.task('css', () => {
return gulp.src(cssPaths.src)
.pipe(autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest(cssPaths.dest));
});
const jsPaths = {
src: `${dirs.src}/js/*.js`,
dest: `${dirs.dest}/js/`
};
const imagesPaths = {
src: `${dirs.src}/images/**/*`,
dest: `${dirs.dest}/images/`
};
gulp.task('build-js', () => {
// set up the browserify instance on a task basis
// var b = browserify({
// entries: ['']
// debug: true
// });
//
// return b.bundle()
// .pipe(source(jsPaths.src))
// .pipe(buffer())
// .pipe(sourcemaps.init({loadMaps: true}))
// // Add transformation tasks to the pipeline here.
// .pipe(uglify())
// .on('error', gutil.log)
// .pipe(sourcemaps.write('.'))
// .pipe(gulp.dest(jsPaths.dest));
return gulp.src(jsPaths.src)
.pipe(gulp.dest(jsPaths.dest));
});
gulp.task('images', () => {
return gulp.src(imagesPaths.src)
.pipe(gulp.dest(imagesPaths.dest));
});
gulp.task('index', () => {
return gulp.src(`${dirs.src}/index.html`)
.pipe(gulp.dest(dirs.dest));
});
gulp.task('clean', (cb) => {
return del(`${dirs.dest}/**/*`, cb);
});
gulp.task('deploy', () => {
return gulp.src(`${dirs.dest}/**/*`)
.pipe(gulp.dest('public'));
});
gulp.task('default', (cb) => {
return runSequence(
['clean'],
['sass'],
['css'],
['build-js'],
['images'],
['index'],
['deploy'],
cb);
});