-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
52 lines (49 loc) · 1.49 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
let gulp = require('gulp');
let rename = require("gulp-rename");
let less = require('gulp-less');
let uglify = require('gulp-uglify');
let header = require('gulp-header');
let LessAutoprefix = require('less-plugin-autoprefix');
let autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] });
let pkg = require('./package.json');
//项目路径
let option = {base: 'src'};
let dist = __dirname + '/dist';
let jsPath = ['src/*.js'];
let lessPath = ['src/*.less'];
let htmlPath = ['src/*.html'];
let banner = [
'/*!',
' * 名称 : adaptable 页面自动适配',
' * 作者 :<%= pkg.author %> <%= pkg.homepage %>',
' * 版本 :<%= pkg.version %>',
' * 日期 :<%= new Date().toLocaleDateString() %>',
' * 兼容 :ios 5+、android 2.3.5+、winphone 8+',
' */',
''].join('\n');
gulp.task('js', () => {
return gulp.src(jsPath, option)
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest(dist))
.pipe(uglify())
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest(dist));
});
gulp.task('less', () =>{
return gulp.src(lessPath, option)
.pipe(less({
plugins: [autoprefix]
}).on('error', function (e) {
console.error(e.message);
this.emit('end');
}))
.pipe(gulp.dest(dist))
})
gulp.task('html', () =>{
return gulp.src(htmlPath, option)
.pipe(gulp.dest(dist))
})
gulp.task('default', ['js', 'less', 'html']);