-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgulpfile.js
More file actions
45 lines (37 loc) · 1.27 KB
/
gulpfile.js
File metadata and controls
45 lines (37 loc) · 1.27 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
const gulp = require('gulp');
const replace = require('gulp-replace');
const header = require('gulp-header');
const uglify = require('gulp-uglify');
const minifyCss = require('gulp-minify-css');
const pkg = require('./package.json');
let note = ["/**\n * <%=name%>\n * v<%=version%>\n * by <%= author %>\n * <%= url %>\n **/\n", pkg];
gulp.task("makejs", function () {
let js = ['src/*.js'];
return gulp.src(js)
.pipe(replace(/\$\{[a-zA-Z]+\}/g, function (match) {
match = match.substr(
match.indexOf('{') + 1,
match.indexOf('}') - 2
);
return pkg[match];
}))
.pipe(uglify())
.pipe(header.apply(null, note))
.pipe(gulp.dest('./dist/'));
});
gulp.task("makecss", function () {
let js = ['src/*.css'];
return gulp.src(js)
.pipe(replace(/\$\{[a-zA-Z]+\}/g, function (match) {
match = match.substr(
match.indexOf('{') + 1,
match.indexOf('}') - 2
);
return pkg[match];
}))
.pipe(minifyCss({
compatibility: 'ie7'
}))
.pipe(header.apply(null, note))
.pipe(gulp.dest('./dist/'));
});