-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
104 lines (91 loc) · 3.36 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
96
97
98
99
100
101
102
103
104
/// <binding AfterBuild='sass' />
var gulp = require('gulp');
var concat = require("gulp-concat");
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var Builder = require('systemjs-builder');
var inlineNg2Template = require("gulp-inline-ng2-template");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("./wwwroot/tsconfig.json");
var runSequence = require('run-sequence');
var tslint = require('gulp-tslint');
var ngc = require('gulp-ngc');
var rollup = require('rollup-stream');
var source = require('vinyl-source-stream');
//production publish task
gulp.task('prod', function (done) {
runSequence('ngc', 'bundle-shims', 'bundle-app', 'bundle-setup-app', 'bundle-conduct-app', 'sass', 'bundle-css', function () {
done();
});
});
gulp.task('lint', function (done) {
gulp.src("./wwwroot/app/**/*.ts")
.pipe(tslint({ formatter: "stylish" }))
.pipe(tslint.report());
});
//sass to css
gulp.task("sass", function () {
return gulp.src('./wwwroot/css/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./wwwroot/css'));
});
//sass to css continuous watch
gulp.task('watch', ['sass'], function () {
gulp.watch('./wwwroot/css/*.scss', ['sass']);
});
//Bundle all css into bundle.css
//TODO: also minify it, and maybe solve relative import errors if any
gulp.task("bundle-css", function () {
return gulp.src([
'./node_modules/bootstrap/dist/css/bootstrap.css',
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
'./wwwroot/css/style.css'
])
.pipe(concat('bundle.css'))
.pipe(gulp.dest('./wwwroot/dist'));
});
//Converts ts files to js with html template inline
gulp.task("tstojs", function () {
return tsProject.src()
.pipe(inlineNg2Template({ base: './wwwroot/', useRelativePaths: true }))
.pipe(tsProject())
.js.pipe(gulp.dest("./wwwroot/app"));
});
//bundle shim files
gulp.task('bundle-shims', function () {
return gulp.src(['./node_modules/core-js/client/shim.js',
'./node_modules/zone.js/dist/zone.js',
'./node_modules/clipboard/dist/clipboard.js',
'./node_modules/jspdf/dist/jspdf.debug.js',
'./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js',
'./node_modules/file-saver/FileSaver.js',
'./node_modules/exceljs/dist/exceljs.js',
'./node_modules/screenfull/dist/screenfull.js',
'./node_modules/@aspnet/signalr-client/dist/browser/signalr-clientES5-1.0.0-alpha2-final.js'
])
.pipe(concat('shims.js'))
.pipe(uglify())
.pipe(gulp.dest('./wwwroot/dist'));
});
//bundle main dashboard app
//gulp-ngc is not compatible with angular 5
gulp.task('ngc', function (done) {
return ngc('./wwwroot/tsconfig.aot.json');
});
gulp.task('bundle-app', () => {
return rollup('wwwroot/rollup-config.js')
.pipe(source('app.bundle.js'))
.pipe(gulp.dest('./wwwroot/dist'));
});
//bundle setup app
gulp.task('bundle-setup-app', function (done) {
return rollup('wwwroot/rollup-config.setup.js')
.pipe(source('app.setup.bundle.js'))
.pipe(gulp.dest('./wwwroot/dist'));
});
//bundle conduct app
gulp.task('bundle-conduct-app', function (done) {
return rollup('wwwroot/rollup-config.conduct.js')
.pipe(source('app.conduct.bundle.js'))
.pipe(gulp.dest('./wwwroot/dist'));
});