forked from eberlitz/material-steppers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (84 loc) · 2.63 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
92
93
94
95
'use strict';
var gulp = require('gulp'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
ts = require('gulp-typescript'),
less = require('gulp-less'),
autoprefixer = require('autoprefixer'),
postcss = require('gulp-postcss'),
cssnano = require('cssnano'),
browserSync = require('browser-sync').create(),
templateCache = require('gulp-angular-templatecache'),
concat = require('gulp-concat'),
orderedMergeStream = require('ordered-merge-stream');
var tsProject = ts.createProject('tsconfig.json', {
noExternalResolve: true
});
var production = true;
gulp.task('default', ['serve']);
gulp.task('build', ['js', 'css']);
gulp.task('templates', function () {
return gulp.src('lib/**/*.tpl.html')
.pipe(templateCache('material-steppers-tpl.js', {
root: 'mdSteppers',
module: 'mdSteppers'
}))
// .pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'));
});
gulp.task('serve', ['build'], function (callback) {
production = false;
browserSync.init({
server: {
baseDir: "./demo",
routes: {
"/lib": "mdSteppers"
}
},
ui: false
});
gulp.watch("lib/*.ts", ['js']);
gulp.watch("lib/*.html", ['js']);
gulp.watch("lib/*.less", ['css']);
gulp.watch("demo/*.html").on('change', browserSync.reload);
});
gulp.task('css', function (callback) {
var stream = gulp.src('lib/*.less')
.pipe(less())
.pipe(postcss([autoprefixer({
browsers: [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
]
})]))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('demo'))
.pipe(postcss([cssnano({
discardComments: { removeAll: true }
})]))
.pipe(gulp.dest('dist'));
return stream;
});
gulp.task('js', ['templates'], function (callback) {
var stream = gulp.src('lib/*.ts')
.pipe(ts(tsProject))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'));
return orderedMergeStream([stream, gulp.src('demo/*-tpl.js')])
.pipe(concat('material-steppers.js'))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('demo'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});