-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
117 lines (101 loc) · 2.69 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
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
'use strict';
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var header = require('gulp-header');
var concat = require('gulp-concat');
var addSrc = require('gulp-add-src');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var prefix = require('gulp-autoprefixer');
var pkg = require('./package.json');
var browserSync = require('browser-sync').create();
var PORT = {
GHOST: '2368',
BROWSERSYNC: '3000'
}
//# Files
//
var dist = (function () {
return {
name: pkg.name,
css: 'assets/dist/css',
js: 'assets/dist/js',
image: 'assets/dist/images',
font: 'assets/dist/fonts'
};
} ());
var src = (function () {
return {
sass: {
main: 'assets/src/scss/main.scss',
files: ['assets/src/scss/**/**']
},
css: {
main: []
},
js: {
main: ['assets/src/js/page.js','assets/src/js/control.js']
},
image: {
files: ['assets/src/images/**/**']
},
font: {
files: ['assets/src/fonts/**/**']
}
};
} ());
var banner = (function () {
return ["/**",
" * <%= pkg.name %> - <%= pkg.description %>",
" * @version <%= pkg.version %>",
" * @link <%= pkg.homepage %>",
" * @author <%= pkg.author.name %> (<%= pkg.author.url %>)",
" * @license <%= pkg.license %>",
" */",
""].join("\n");
} ());
//# tasks
//
gulp.task('css', function () {
gulp.src(src.css.main)
.pipe(plumber())
.pipe(addSrc(src.sass.main))
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(prefix())
.pipe(concat(pkg.name + '.min.css'))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest(dist.css));
});
gulp.task('js', function () {
gulp.src(src.js.main)
.pipe(plumber())
.pipe(concat(pkg.name + '.min.js'))
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest(dist.js));
});
gulp.task('image', function () {
gulp.src(src.image.files)
.pipe(imagemin())
.pipe(gulp.dest(dist.image));
});
gulp.task('font', function () {
gulp.src(src.font.files)
.pipe(gulp.dest(dist.font));
});
gulp.task('server', function () {
browserSync.init({
proxy: "http://127.0.0.1:#{PORT.GHOST}"
});
});
gulp.task('build', ['css', 'js','image','font']);
gulp.task('default', function () {
gulp.start(['build']);
gulp.watch(src.js.main, ['js']);
gulp.watch(src.sass.files, ['css']);
gulp.watch(src.font.files, ['font']);
gulp.watch(src.image.files, ['image']);
});