forked from suruibuas/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
130 lines (124 loc) · 2.9 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const header = require('gulp-header');
const less = require('gulp-less');
const cssmin = require('gulp-minify-css');
const plumber = require('gulp-plumber');
const babel = require('gulp-babel');
const sync = require('browser-sync').create();
const reload = sync.reload;
// 定义通用注释
var note = "/*!\r\n eadmin极速后台UI框架(我只想要个后台) | @author:317953536@qq.com \r\n*/\r\n";
// 开发模式
gulp.task('dev', [
'jsmin'
], function() {
sync.init({
server: {
baseDir: './dist'
},
browser: 'chrome'
});
// 编译类库
gulp.watch([
'src/js/**/*.js'
], ['jsmin']);
// 编辑less
gulp.watch('src/less/**/*.less', ['less']);
// 合并CSS
gulp.watch('src/css/**/*.css', ['css']).on('change', reload);
// 重载
gulp.watch([
'dist/js/**/*.js',
'dist/css/**/*.css',
'dist/html/**/*.html',
'dist/demo/**/*.html'
]).on('change', reload);
});
// 运行模式
gulp.task('run', [], function() {
sync.init({
server: {
baseDir: './dist'
},
browser: 'chrome'
});
});
// 压缩JS
gulp.task('jsmin', function(){
// 压缩核心类,函数,初始化文件
gulp.src([
'src/js/core/al.load.js'
]).
pipe(plumber()).
pipe(babel()).
pipe(uglify()).
pipe(rename({
suffix : '.min'
})).
pipe(header(note)).
pipe(gulp.dest('dist/js/core'));
// 压缩核心类,函数,初始化文件
gulp.src([
'src/js/core/al.conf.js',
'src/js/core/al.func.js',
'src/js/core/al.init.js'
]).
pipe(plumber()).
pipe(babel()).
pipe(concat('al.init.js')).
pipe(uglify()).
pipe(rename({
suffix : '.min'
})).
pipe(header(note)).
pipe(gulp.dest('dist/js/core'));
// 压缩类库
gulp.src([
'src/js/lib/*.js'
]).
pipe(plumber()).
pipe(babel()).
pipe(uglify()).
pipe(rename({
suffix : '.min'
})).
pipe(header(note)).
pipe(gulp.dest('dist/js/lib'));
// 压缩框架
gulp.src([
'src/js/framework/eadmin/1.0.1/*.js'
]).
pipe(plumber()).
pipe(babel()).
pipe(uglify()).
pipe(rename({
suffix : '.min'
})).
pipe(header(note)).
pipe(gulp.dest('dist/js/framework/eadmin/1.0.1'));
});
//编译less
gulp.task('less', function(){
gulp.src([
'src/less/**/*.less',
'!src/less/global.less'
]).
pipe(plumber()).
pipe(less()).
pipe(gulp.dest('src/css'));
});
//合并css
gulp.task('css', function(){
return gulp.src([
'src/css/*.css',
'src/css/common/*.css',
'src/css/lib/*.css',
]).
pipe(plumber()).
pipe(concat('eadmin.min.css')).
pipe(cssmin()).
pipe(gulp.dest('dist/css'));
});