-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
138 lines (113 loc) · 3.58 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
/**
* CPortal dependencies
*
* @type {Gulp}
*/
const { src, dest, parallel } = require( 'gulp' );
const sass = require( 'gulp-sass' );
const uglify = require( 'gulp-uglify' );
const cleanCSS = require( 'gulp-clean-css' );
const rename = require( 'gulp-rename' );
function exclude_css( path ) {
var exclude = ['assets/' + path + '/sass/*.sass'];
if ( path === 'admin' ) {
} else if ( path === 'front' ) {
exclude.push( '!assets/' + path + '/sass/suggest.sass' );
exclude.push( '!assets/' + path + '/sass/dropdown.sass' );
exclude.push( '!assets/' + path + '/sass/notice.sass' );
exclude.push( '!assets/' + path + '/sass/tooltip.sass' );
}
return exclude;
}
function js( path ) {
return src( ['assets/' + path + '/js/*.js', '!assets/' + path + '/js/*.min.js'] )
.pipe( uglify() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/' + path + '/js' ) );
}
function css( path ) {
sass.compiler = require( 'node-sass' );
var src_array = exclude_css( path );
return src( src_array )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( dest( 'assets/' + path + '/css' ) );
}
function min_css( path ) {
sass.compiler = require( 'node-sass' );
var src_array = exclude_css( path );
return src( src_array )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( cleanCSS() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/' + path + '/css' ) );
}
function fontsmax() {
return src( 'assets/common/libs/fontawesome/scss/*.scss' )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( dest( 'assets/common/libs/fontawesome/css' ) );
}
function fontsmin() {
return src( 'assets/common/libs/fontawesome/scss/*.scss' )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( cleanCSS() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/common/libs/fontawesome/css' ) );
}
function minify_libs() {
return src( ['assets/common/css/jquery-ui.css'] )
.pipe( cleanCSS() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/common/css/' ) );
}
exports.admin_js = js( 'admin' );
exports.admin_css = css( 'admin' );
exports.admin_min_css = min_css( 'admin' );
exports.common_js = js( 'common' );
exports.common_css = css( 'common' );
exports.common_min_css = min_css( 'common' );
exports.front_js = js( 'frontend' );
exports.front_css = css( 'frontend' );
exports.front_min_css = min_css( 'frontend' );
exports.fontsmax = fontsmax;
exports.fontsmin = fontsmin;
exports.minify_libs = minify_libs;
function admin() {
parallel( js( 'admin' ), css( 'admin' ), min_css( 'admin' ) );
}
function common() {
parallel( js( 'common' ), css( 'common' ), min_css( 'common' ) );
}
function front() {
parallel( js( 'frontend' ), css( 'frontend' ), min_css( 'frontend' ) );
}
function common_css() {
return src( ['assets/common/libs/tipsy/css/*.css', '!assets/common/tipsy/css/*.min.css'] )
.pipe( cleanCSS() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/common/libs/tipsy/css' ) );
}
function common_js() {
return src( ['assets/common/libs/tipsy/js/*.js', '!assets/common/tipsy/js/*.min.js'] )
.pipe( uglify() )
.pipe( rename( { suffix: '.min' } ) )
.pipe( dest( 'assets/common/libs/tipsy/js' ) );
}
exports.common_css = common_css;
exports.common_js = common_js;
function common_libs( done ) {
parallel( common_css, common_js );
done();
}
function fonts() {
parallel( fontsmax, fontsmin );
}
exports.admin = admin;
exports.front = front;
exports.common = common;
exports.common_libs = common_libs;
exports.fonts = fonts;
function defaultTask( done ) {
parallel( admin, front, common );
done();
}
exports.default = defaultTask;