-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
169 lines (157 loc) · 5.01 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
*
* Gulpfile setup
*
* @since 1.0.0
* @authors @tianmarin
* @package noidea
*/
// Config
var config = {
assetsPath : './assets',
lessPath : './assets/less',
bowerDir : './bower_components'
}
var gulp = require('gulp');
// Load plugins
var gulpLoadPlugins = require('gulp-load-plugins'),
$ = gulpLoadPlugins();
// Styles
gulp.task('templateStyle', function () {
return gulp.src([
// additional packages
// './bower_components/jquery-ui-bootstrap/jquery.ui.theme.font-awesome.css',
// './bower_components/bootstrap-daterangepicker/daterangepicker.css',
'./assets/less/template/*.less',
'./bower_components/select2/dist/css/select2.css',
])
.pipe($.sourcemaps.init())
//.pipe(plugins.flatten())
.pipe($.concat('csi-template-style.less'))
.pipe($.less({
//paths: [ plugins.path.join(__dirname, 'less', 'includes') ]
}))
//.pipe($.cleanCss({compatibility: 'ie8'}))
.pipe($.stripCssComments({preserve:false}))
// .pipe($.cleanCss())
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/css'))
.pipe($.notify('Template Style compilation done!'));
});
gulp.task('shortcodeStyle', function () {
return gulp.src([
'./assets/less/shortcode/*.less',
// additional packages
'./bower_components/jquery-ui-bootstrap/jquery.ui.theme.font-awesome.css',
'./bower_components/bootstrap-daterangepicker/daterangepicker.css',
])
.pipe($.sourcemaps.init())
//.pipe(plugins.flatten())
.pipe($.concat('csi-shortcode-style.less'))
.pipe($.less({
//paths: [ plugins.path.join(__dirname, 'less', 'includes') ]
}))
.pipe($.cleanCss({compatibility: 'ie8'}))
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/css'))
.pipe($.notify('Shortcode Style compilation done!'));
});
//Scripts
gulp.task('templateScript', function () {
return gulp.src([
'./assets/js/templates/*.js',
])
.pipe($.sourcemaps.init())
.pipe($.jshint())
.pipe($.jshint.reporter('default'))
//.pipe($.uglify())
.pipe($.concat('csi-template-js.js'))
.pipe($.rename({
suffix: ".min",
extname: ".js"
}))
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/js'))
.pipe($.notify('Template Script compilation done!'));
});
// Uglify Plugins
gulp.task('uglifyVendor', function() {
return gulp.src([
'./bower_components/bootstrap/dist/js/bootstrap.js',
'./bower_components/jquery-confirm2/js/jquery-confirm.js',
'./bower_components/select2/dist/js/select2.js',
])
.pipe($.sourcemaps.init())
.pipe($.concat('vendor.js'))
.pipe($.rename({
suffix: ".min",
extname: ".js"
}))
//.pipe($.uglify())
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/js'))
.pipe($.notify('Template Script compilation done!'));
});
// Fonts
gulp.task('fonts', function() {
return gulp.src([config.bowerDir + '/**/fontawesome-webfont.*'])
.pipe($.sourcemaps.init())
.pipe(plugins.flatten())
.pipe($.sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/fonts'));
});
// Images
gulp.task('images', function () {
return gulp.src([
'assets/images/**/*',
'assets/lib/images/*'])
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('./dist/images'))
.pipe($.size());
});
// Clean
gulp.task('clean', function () {
return gulp.src(['dist/css', 'dist/js', 'dist/images'], { read: false }).pipe($.clean());
});
// Build
gulp.task('build', ['templateStyle', 'shortcodeStyle', 'images', 'fonts']);
// Default task
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
var browserSync = require('browser-sync').create();
gulp.task('watch', function () {
gulp.watch(config.assetsPath + '/**/*.less', ['templateStyle']);
gulp.watch(config.assetsPath + '/**/*.js', ['templateScript']);
gulp.watch(config.assetsPath + './gulpfile.js', ['uglifyVendor']);
//gulp.watch(config.assetsPath + "/**/*.php").on('change', browserSync.reload);
});
gulp.task('browser-sync', function() {
browserSync.init({
files: "./**/*.*",
proxy: "localhost",
});
});
/*
gulp.task('build-less', function() {
return gulp.src(config.lessPath + '/style.less')
.pipe(sourcemaps.init())
.pipe(less({
// outputStyle: 'compressed',
sourceMap: true,
includePaths: [
'./assets/less',
config.bowerDir + '/bootstrap-sass/assets/stylesheets',
config.bowerDir + '/font-awesome/scss',
],
}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/css'))
.pipe(browserSync.stream())
.pipe(notify('Less compilation done'));
});
*/