-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
145 lines (122 loc) · 4 KB
/
gruntfile.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var path = require('path');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt, {});
var modRewrite = require('connect-modrewrite');
var watchPort = 35729;
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
livereload: {
port: watchPort
}
},
client_typescript: {
files: ['src/client/**/*.ts'],
tasks: ['exec:client_typescript', 'browserify:dev']
},
server_typescript: {
files: ['src/server/**/*.ts'],
tasks: ['ts:server']
},
html: {
files: ['src/client/index.html'],
tasks: ['copy:html']
},
hapi: {
files: ['dist/server/**/*.js'],
tasks: ['hapi:custom_options'],
options: {
spawn: false
}
},
less: {
files: ['src/client/**/*.less'],
tasks: ['less']
}
},
ts: {
// A specific target
server: {
src: ["src/server/**/*.ts"],
outDir: 'dist/server/',
//html: 'src/**/*.html',
options: {
target: 'es5', // 'es3' (default) | 'es5'
module: 'commonjs', // 'amd' (default) | 'commonjs'
sourceMap: false, // true (default) | false
declaration: false, // true | false (default)
removeComments: true, // true (default) | false
fast: 'never'
}
}
},
browserify: {
dev: {
options: {
debug: true,
transform: ['reactify']
},
files: {
'dist/client/bundle.js': 'dist/client/app/app.js'
}
},
build: {
options: {
debug: false,
transform: ['reactify']
},
files: {
'dist/client/bundle.js': 'dist/client/app/app.js'
}
}
},
exec: {
client_typescript: {
cmd: './node_modules/.bin/jsx-tsc --module CommonJS --outDir dist/client/app src/client/app/app.ts'
}
},
clean: ['dist/'],
copy: {
html: {
files: [
{expand: true, flatten: true, cwd: 'src/client/', src: ['index.html'], dest: 'dist/client/', filter: 'isFile'}
]
}
},
less: {
client: {
files: {
"dist/client/main.css": "src/client/main.less"
}
}
},
hapi: {
custom_options: {
options: {
server: path.resolve('./dist/server/server')
}
}
},
connect: {
dist: {
options: {
open: true,
livereload: watchPort,
protocol: 'http',
port: 9000,
middleware: function (connect, options) {
return [
// Rewrite requests to root so they may be handled by router
modRewrite(['^[^\\.]*$ /index.html [L]']),
// Serve static files
connect.static('dist/client/')
];
}
}
}
}
});
grunt.registerTask('default', ['build', 'hapi', 'connect:dist', 'watch']);
grunt.registerTask('build', ['clean', 'ts:server', 'exec:client_typescript', 'browserify:dev', 'less', 'copy:html']);
};