forked from dukezing/corethink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
128 lines (106 loc) · 3.16 KB
/
gulpfile.js
File metadata and controls
128 lines (106 loc) · 3.16 KB
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
// gulp 安裝命令
// @author Jason 封仁杰 <solidzoro@live.com>
// @lastdate 2015-08-05 15:51:03
//
// npm install gulp autoprefixer strftime gulp-less gulp-autoprefixer gulp-concat gulp-jade gulp-jshint gulp-uglify gulp-jshint gulp-coffee gulp-header gulp-rename gulp-sourcemaps gulp-minify-css gulp-livereload gulp-watch --save-dev
//
//
// init module
// --------------------------------------------
var gulp = require('gulp');
var less = require('gulp-less');
// var minifyCSS = require('gulp-minify-css');
// var sourcemaps = require('gulp-sourcemaps');
var prefix = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var strftime = require('strftime');
var header = require('gulp-header');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');
// var jsincluder = require('gulp-jsincluder');
//
//
// mod module
// --------------------------------------------
var gulp_date_now = strftime('%F %T'); // mod current time
var gulp_comment_banner = '/*! * <%= date %> */\n\n'; // mod ASCII banner
//
//
// ADMIN
// --------------------------------------------
var ADMIN = {
ROOT: 'Application/Admin',
VIEW: 'Application/Admin/View',
};
// SCRIPT ADMIN
var admin_script_files = [
"Public/libs/bootstrap/js/transition.js",
"Public/libs/bootstrap/js/alert.js",
"Public/libs/bootstrap/js/button.js",
"Public/libs/bootstrap/js/carousel.js",
"Public/libs/bootstrap/js/collapse.js",
"Public/libs/bootstrap/js/dropdown.js",
"Public/libs/bootstrap/js/modal.js",
"Public/libs/bootstrap/js/tooltip.js",
"Public/libs/bootstrap/js/popover.js",
"Public/libs/bootstrap/js/scrollspy.js",
"Public/libs/bootstrap/js/tab.js",
"Public/libs/bootstrap/js/affix.js",
];
gulp.task('admin_script_module', function() {
gulp
.src(admin_script_files)
.pipe(concat('admin_source.js'))
.pipe(gulp.dest('Public/js/'))
.pipe(uglify()).pipe(rename('admin.js'))
.pipe(header(gulp_comment_banner, {
date: gulp_date_now
}))
.pipe(gulp.dest('Public/js/'));
});
// STYLE ADMIN
var admin_style_files = [
ADMIN.VIEW + "/_Resource/less/admin.less",
];
gulp.task('admin_style_module', function() {
gulp
.src(admin_style_files)
.pipe(less())
.pipe(prefix())
.pipe(rename('admin.css'))
.pipe(header(gulp_comment_banner, {
date: gulp_date_now
}))
.pipe(gulp.dest('Public/css/'))
.pipe(livereload());
});
//
//
// 监听
// --------------------------------------------
gulp.task('watching', function() {
// TASK
gulp.watch(admin_script_files, ['admin_script_module']);
gulp.watch(ADMIN.ROOT + '/**/*.less', ['admin_style_module']);
// LIVERELOAD
livereload.listen();
gulp.watch([
'index.php',
ADMIN.ROOT + '/**/*.php',
ADMIN.ROOT + '/**/*.less',
], function(event) {
livereload.changed(event.path);
});
});
//
//
// 运行
// --------------------------------------------
gulp.task('default', [
// 后端
'admin_script_module',
'admin_style_module',
// 监听
'watching'
]);