-
Notifications
You must be signed in to change notification settings - Fork 83
/
gulpfile.js
92 lines (80 loc) · 2.71 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var path = require('path');
var del = require('del');
var series = require('stream-series');
var gulp = require('gulp');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var webserver = require('gulp-webserver');
var templateCache = require('gulp-angular-templatecache');
var minifyCss = require('gulp-minify-css');
var minifyHtml = require('gulp-minify-html');
var uglify = require('gulp-uglify');
var stylus = require('gulp-stylus');
var KarmaServer = require('karma').Server;
var autoprefixer = require('autoprefixer-stylus')({
browsers: ["ff >= 20", "chrome >= 35", "safari >= 7", "ios >= 7", "android >= 4", "opera >= 12.1", "ie >= 10"]
});
var paths = {
root: __dirname,
src: path.join(__dirname, '/src'),
dist: path.join(__dirname, '/dist')
};
gulp.task('webserver', function() {
return gulp.src(paths.root)
.pipe(webserver({
host: 'localhost',
port: 3000,
fallback: 'index.html',
livereload: true
}));
});
gulp.task('clean', function() {
del.sync(paths.dist);
});
gulp.task('compileStyles', function() {
return gulp.src(path.join(paths.src, 'style.styl'))
.pipe(stylus({
use: autoprefixer
}))
.pipe(concat('select.css'))
.pipe(gulp.dest(paths.dist))
.pipe(minifyCss())
.pipe(rename('select.min.css'))
.pipe(gulp.dest(paths.dist))
});
gulp.task('compileScripts', function() {
var templateStream = gulp.src(path.join(paths.src, 'template.html'))
.pipe(minifyHtml())
.pipe(templateCache({
module: 'oi.select',
root: 'src/'
}));
var scriptStream = gulp.src([
path.join(paths.src, 'module.js'),
path.join(paths.src, 'services.js'),
path.join(paths.src, 'directives.js'),
path.join(paths.src, 'filters.js')
]);
scriptStream
.pipe(concat('select.js'))
.pipe(gulp.dest(paths.dist))
.pipe(uglify())
.pipe(rename('select.min.js'))
.pipe(gulp.dest(paths.dist));
series(scriptStream, templateStream)
.pipe(concat('select-tpls.js'))
.pipe(gulp.dest(paths.dist))
.pipe(uglify())
.pipe(rename('select-tpls.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('watch', function() {
gulp.watch(path.join(paths.src, '**/*.styl'), ['compileStyles']);
});
gulp.task('test', function(done) {
new KarmaServer({
configFile: path.join(paths.root, 'karma.conf.js')
}, done).start();
});
gulp.task('build', ['clean', 'compileScripts', 'compileStyles']);
gulp.task('default', ['webserver', 'watch']);