-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
140 lines (116 loc) · 3.33 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var browserSync = require('browser-sync').create();
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var cssSource = 'app/styles/styles.scss';
var allCssSource = 'app/styles/**/**.scss';
var htmlSource = 'app/html/**/*.html';
var imgSource = 'app/img/**/*.*';
var jsSource = 'app/js/**/*.js';
var jsLibSource = 'app/lib/**/*.js';
var translationsSource = 'app/translations/*.js';
var dist = "./dist";
var dist_deploy = "../dist";
gulp.task('default', ['img', 'sass', 'js-lib', 'js', 'html', 'browserSync'], function () {
gulp.watch(allCssSource, ['sass']);
gulp.watch(htmlSource, ['html']);
gulp.watch(jsSource, ['js']);
gulp.watch(translationsSource, ['js']);
gulp.watch(imgSource, ['img']);
});
gulp.task('deploy', ['img-deploy', 'sass-deploy', 'js-lib-deploy', 'js-deploy', 'html-deploy'], function () {
});
gulp.task('deploy-no-lib', ['img-deploy', 'sass-deploy', 'js-deploy', 'html-deploy'], function () {
});
gulp.task('img', function () {
return gulp.src(imgSource)
.pipe(gulp.dest(dist + '/img'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('img-deploy', function () {
return gulp.src(imgSource)
.pipe(gulp.dest(dist_deploy + '/img'));
});
gulp.task('sass', function () {
return gulp.src(cssSource)
.pipe(concat('styles.css'))
.pipe(sass())
.pipe(gulp.dest(dist + '/css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('sass-deploy', function () {
return gulp.src(cssSource)
.pipe(concat('styles.css'))
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest(dist_deploy + '/css'));
});
gulp.task('js-lib', function () {
return gulp.src(jsLibSource)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('lib.js'))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist + '/js'));
});
gulp.task('js-lib-deploy', function () {
return gulp.src(jsLibSource)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat('lib.js'))
.pipe(uglify())
.on('error', gutil.log)
.pipe(gulp.dest(dist_deploy + '/js'));
});
gulp.task('js', function () {
var b = browserify({
entries: './app/js/entry.js',
debug: true
});
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist + '/js'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('js-deploy', function () {
var b = browserify({
entries: './app/js/entry.js',
debug: false
});
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(uglify())
.on('error', gutil.log)
.pipe(gulp.dest(dist_deploy + '/js'));
});
gulp.task('html', function () {
return gulp.src(htmlSource)
.pipe(gulp.dest(dist));
});
gulp.task('html-deploy', function () {
return gulp.src(htmlSource)
.pipe(gulp.dest(dist_deploy));
});
gulp.task('browserSync', function () {
browserSync.init({
server: {
baseDir: dist
},
});
});
//7f17680f-a964-4aa1-8af8-8130b54e41fe