-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
119 lines (89 loc) · 3.24 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var gulp = require('gulp');
var del = require('del');
var ts = require('gulp-typescript');
var symlink = require('gulp-symlink');
var sass = require('gulp-sass');
var replace = require('gulp-replace');
var pug = require('gulp-pug');
gulp.task('clean', function () {
// Remove 'bin' directory
return del(['bin/**']);
});
gulp.task('build::api', function(){
// Build server code
var apiProject = ts.createProject(
'src/api/tsconfig.json',
{ typescript: require('typescript') }
);
return gulp.src(['src/api/**/*.ts'])
.pipe(apiProject())
.on('error', function() { process.exit(1) })
.pipe(gulp.dest('bin/api'))
});
gulp.task('build::app', function(){
// Build client code
var appProject = ts.createProject(
'src/app/tsconfig.json',
{ typescript: require('typescript') }
);
return gulp.src(['src/app/**/*.ts'])
.pipe(appProject())
.on('error', function() { process.exit(1) })
.pipe(gulp.dest('bin/app'));
});
gulp.task('build', ['build::api', 'build::app']); // Build server, and client code
gulp.task('static::app::root', function(){
// Copy static files in the root directory
return gulp.src(['src/app/index.html',
'src/app/systemjs.config.js'])
.pipe(gulp.dest('bin/app'))
});
gulp.task('static::app::views', function(){
// Copy views HTML files
return gulp.src(['src/app/views/**/*.html'])
.pipe(gulp.dest('bin/app/views'))
});
gulp.task('symlink::node_modules', function(){
// Create a symlink to 'node_modules'
return gulp.src('node_modules')
.pipe(symlink('bin/app/node_modules', {force: true}))
});
gulp.task('symlink::api', function(){
// Create a symlink to 'api'
return gulp.src('bin/api')
.pipe(symlink('bin/app/api', {force: true}))
});
gulp.task('materialize::replace', function() {
// Set materialize-css theme color
return gulp.src(['node_modules/materialize-css/sass/components/_variables.scss'])
.pipe(replace('../fonts/roboto/', 'fonts/roboto/'))
.pipe(replace(/primary-color: color\(.*?\)/, 'primary-color: color("light-blue", "lighten-1")'))
.pipe(replace(/secondary-color: color\(.*?\)/, 'secondary-color: color("light-green", "base")'))
.pipe(gulp.dest('node_modules/materialize-css/sass/components'));
});
gulp.task('materialize::fonts', function() {
// Create a symlink for materialize-css fonts
return gulp.src('node_modules/materialize-css/fonts')
.pipe(symlink('bin/app/styles/fonts', {force: true}))
});
gulp.task('materialize', ['materialize::replace', 'materialize::fonts']);
gulp.task('styles', ['materialize'], function () {
// Compile dictio.scss
return gulp.src(['src/app/styles/dictio.scss', 'node_modules/materialize-css/sass/materialize.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('bin/app/styles'));
});
gulp.task('pug', function () {
// Compile view HTML files
return gulp.src('src/app/views/**/*.pug')
.pipe(pug({ pretty: true }))
.pipe(gulp.dest('bin/app/views'));
});
gulp.task('static', ['pug', 'static::app::root', 'styles', 'static::app::views', 'symlink::node_modules', 'symlink::api']);
gulp.task('buildall', ['build'], function() {
gulp.start('static')
});
gulp.task('rebuild', ['clean'], function () {
gulp.start('buildall');
});
gulp.task('default', ['rebuild']);