-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
46 lines (41 loc) · 1.3 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
var gulp = require('gulp'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
header = require('gulp-header'),
include = require('gulp-file-include'),
postcss = require('gulp-postcss'),
template = ['/*!',
' * <%= name %> <%= version %>',
' * <%= description %>',
' * <%= homepage %>',
' * ',
' * Released under the <%= license %> license',
' * Copyright (c) <%= new Date().getFullYear() %>, <%= author %>',
' */\n\n'].join('\n');
gulp.task('css', function () {
var pkg = JSON.parse(require('fs').readFileSync('package.json'));
return gulp.src('src/' + pkg.name + '.css')
.pipe(postcss([
require('postcss-easings')(),
require('autoprefixer-core')('last 2 versions')
]))
.pipe(header(template, pkg))
.pipe(gulp.dest('dist'));
});
gulp.task('js', function () {
var pkg = JSON.parse(require('fs').readFileSync('package.json'));
return gulp.src('src/' + pkg.name + '.js')
.pipe(include('// @@'))
.pipe(header(template, pkg))
.pipe(gulp.dest('dist'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['css', 'js'])
gulp.task('dev', ['default'], function () {
gulp.watch(['package.json', 'src/**/*.js'], ['js']);
gulp.watch(['package.json', 'src/*.css'], ['css']);
})