forked from projectsend/projectsend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
125 lines (110 loc) · 4.21 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
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const babel = require('gulp-babel');
// const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
// const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const pump = require('pump');
let sassFiles = 'assets/src/scss/main.scss';
let sassPartials = 'assets/src/scss/partials/**/*.scss';
let assetsCss = [
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/font-awesome/css/font-awesome.min.css',
'node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css',
'node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css',
'node_modules/chosen-js/chosen.min.css',
'node_modules/footable/css/footable.core.min.css',
'node_modules/@yaireo/tagify/dist/tagify.css',
'vendor/moxiecode/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css'
];
let assetsJs = [
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js',
'node_modules/bootstrap-toggle/js/bootstrap-toggle.min.js',
'node_modules/chosen-js/chosen.jquery.min.js',
'node_modules/footable/dist/footable.min.js',
'node_modules/node-jen/jen.js',
'node_modules/@yaireo/tagify/dist/jQuery.tagify.min.js',
'node_modules/js-cookie/src/js.cookie.js',
'node_modules/jquery-validation/dist/jquery.validate.min.js',
'node_modules/sprintf-js/dist/sprintf.min.js',
'assets/lib/flot/jquery.flot.min.js',
'assets/lib/flot/jquery.flot.resize.min.js',
'assets/lib/flot/jquery.flot.time.min.js',
'vendor/moxiecode/plupload/js/plupload.full.min.js',
'vendor/moxiecode/plupload/js/jquery.plupload.queue/jquery.plupload.queue.min.js'
];
let appJs = [
'assets/src/js/obj.js',
'assets/src/js/main.js',
'assets/src/js/pages/*.js',
'assets/src/js/parts/*.js'
];
let dest = 'assets/';
gulp.task('sass', function () {
gulp.src(sassFiles)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(concat('main.css'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'css/'));
gulp.src(assetsCss)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(concat('assets.css'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'css/'));
});
gulp.task('javascript', function () {
gulp.src(appJs)
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'js/'));
gulp.src(assetsJs)
.pipe(sourcemaps.init())
.pipe(concat('assets.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest + 'js/'));
});
gulp.task('copy', function () {
gulp.src('node_modules/bootstrap/fonts/*.*')
.pipe(gulp.dest(dest + 'fonts/'));
gulp.src('node_modules/font-awesome/fonts/*.*')
.pipe(gulp.dest(dest + 'fonts/'));
gulp.src('node_modules/footable/css/fonts/*.*')
.pipe(gulp.dest(dest + 'fonts/'));
gulp.src('node_modules/chosen-js/*.png')
.pipe(gulp.dest(dest + 'img/'));
gulp.src('node_modules/jquery/dist/jquery.min.js')
.pipe(gulp.dest(dest + 'lib/jquery/'));
gulp.src('node_modules/jquery-migrate/dist/jquery-migrate.min.js')
.pipe(gulp.dest(dest + 'lib/jquery-migrate/'));
});
gulp.task('minify-css', function () {
return gulp.src(dest + 'css/*.css')
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(dest + 'css/'));
});
gulp.task('minify-js', function (cb) {
pump([
gulp.src(dest + 'js/*.js'),
uglify(),
rename({ suffix: '.min' }),
gulp.dest(dest + 'js/')
], cb);
});
gulp.task('minify', ['minify-css', 'minify-js']);
gulp.task('build', ['copy', 'sass', 'javascript']);
gulp.task('prod', ['build', 'minify']);
gulp.task('watch', function () {
gulp.watch(sassFiles, ['copy']);
gulp.watch([sassFiles, sassPartials], ['sass']);
gulp.watch([appJs], ['javascript']);
});
gulp.task('default', ['build', 'watch']);