-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
68 lines (65 loc) · 1.82 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
var pkg = require('./package.json'),
gulp = require('gulp'),
rename = require('gulp-rename'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
header = require('gulp-header'),
browserSync = require('browser-sync').create();
var banner = ['/**',
' * <%= pkg.title %> - <%= pkg.description %>',
' * @authors <%= pkg.author.name %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.licenses.type %>',
' */',
''
].join('\n');
gulp.task('concat-css', function () {
return gulp.src('src/css/*.css')
.pipe(concat(`${pkg.name}.css`))
.pipe(gulp.dest('dist'));
});
gulp.task('concat-js', function () {
return gulp.src('src/*.js')
.pipe(concat(`${pkg.name}.js`))
.pipe(gulp.dest('dist'));
});
gulp.task('minify-css', function () {
return gulp.src(`dist/${pkg.name}.css`)
.pipe(rename({
suffix: '.min'
}))
.pipe(cleanCSS())
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('dist'));
});
gulp.task('minify-js', function () {
return gulp.src(`dist/${pkg.name}.js`)
.pipe(rename({
suffix: '.min'
}))
.pipe(uglify())
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('dist'));
});
gulp.task('browser-reload', ['default'], function (done) {
browserSync.reload();
done();
});
gulp.task('default', ['concat-css', 'concat-js']);
gulp.task('release', ['default'], function () {
gulp.start(['minify-js', 'minify-css']);
});
gulp.task('develop', ['default'], function () {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(["src/**/*", "test/**/*"], ['browser-reload']);
});