forked from sc-date-time/sc-date-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
69 lines (63 loc) · 2.18 KB
/
gulpfile.babel.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
// dependencies
import fs from 'fs';
import gulp from 'gulp';
import git from 'gulp-git';
import bump from 'gulp-bump';
import filter from 'gulp-filter';
import tagVersion from 'gulp-tag-version';
import del from 'del';
import concat from 'gulp-concat-util';
import order from 'gulp-order';
import rename from 'gulp-rename';
import runSequence from 'run-sequence';
import changelog from 'conventional-changelog';
import stylus from 'gulp-stylus';
import autoprefixer from 'gulp-autoprefixer';
import babel from 'gulp-babel';
import jade from 'gulp-jade';
import ngtemplate from 'gulp-ngtemplate';
import htmlmin from 'gulp-htmlmin';
gulp.task('clean:dist', cb => del(['dist/*'], cb));
gulp.task('compile:jade', ['clean:dist'], () =>
gulp.src(['./src/*.jade'])
.pipe(jade({ pretty: true }))
.pipe(rename({ prefix: 'scDateTime-', extname: '.tpl' }))
.pipe(gulp.dest('dist'))
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(ngtemplate({ module: 'scDateTime' }))
.pipe(rename({ extname: '.tpl.temp' })) // for temp file cleanup
.pipe(gulp.dest('dist')),
);
gulp.task('compile:babel', ['compile:jade'], () =>
gulp.src(['./src/main.js'])
// Lint the coffescript
.pipe(babel({
presets: [['env', {
modules: 'umd',
targets: {
browsers: 'last 2 versions',
},
}]],
}))
.pipe(rename('sc-date-time.js'))
.pipe(gulp.dest('dist')),
);
gulp.task('compile:javascript', ['compile:babel'], () => {
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
return gulp.src(['./dist/sc-date-time.js', './dist/*.tpl.temp'])
.pipe(order(['dist/sc-date-time.js', 'dist/*.tpl.temp']))
.pipe(concat('sc-date-time.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('compile:stylus', ['clean:dist'], () => {
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
return gulp.src(['./src/styles.styl'])
.pipe(stylus())
.pipe(autoprefixer())
.pipe(concat())
.pipe(rename('sc-date-time.css'))
.pipe(gulp.dest('dist'));
});
gulp.task('compile:main', ['compile:javascript', 'compile:stylus']);
gulp.task('compile', ['compile:main'], cb => del(['dist/*.temp'], cb));
gulp.task('default', ['compile']);