-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGruntfile.coffee
145 lines (128 loc) · 3.06 KB
/
Gruntfile.coffee
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
'use strict';
lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet
mountFolder = (connect, dir) ->
connect.static(require('path').resolve(dir))
module.exports = (grunt) ->
# load all grunt tasks
require('matchdep')
.filterDev('grunt-*')
.forEach(grunt.loadNpmTasks)
# Project configuration.
grunt.initConfig {
pkg: grunt.file.readJSON('package.json'),
# clean the dist folder before building
clean: {
test: {
src: [".tmp"]
},
build: {
src: ["dist"]
}
},
# compile all the coffee script files into one file
coffee: {
test: {
options: {
sourceMap: true,
},
files: {
'.tmp/unit-test.js': ['test/unit/**/*.coffee'] # compile and concat into single file
'.tmp/angular-servicestack.js': ['src/**/*.coffee'] # compile and concat into single file
}
},
build: {
files: {
'dist/angular-servicestack-<%= pkg.version %>.js': ['src/**/*.coffee'] # compile and concat into single file
}
}
},
concat: {
options: {
banner: '<%= meta.banner %>'
},
build: {
files: {
'dist/angular-servicestack-<%= pkg.version %>.js': ['dist/angular-servicestack-<%= pkg.version %>.js']
}
},
},
# configure test server
connect: {
options: {
port: 34543,
hostname: 'localhost'
},
test: {
options: {
middleware: (connect) ->
[
mountFolder(connect, '.tmp'),
]
}
}
},
# copy files that don't need to be processed to the dist tree
copy: {
test: {
files: [{
expand: true,
cwd: 'test/', # change the current working directory to app, so all file are written to dist at the correct level
src: [
'config/**'#, # copy all files in the config folder
'lib/**'#, # copy all files in the config folder
#'lib/**' # copy all files in the lib folder
],
dest: '.tmp/'
}]
}
},
karma: {
unit: {
configFile: ".tmp/config/karma.conf.js",
singleRun: true
}
},
meta: {
banner: '/**\n' +
' * @name: <%= pkg.name %>\n' +
' * @description: <%= pkg.description %>\n' +
' * @version: v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @link: <%= pkg.homepage %>\n' +
' * @author: <%= pkg.author %>\n' +
' * @license: MIT License, http://www.opensource.org/licenses/MIT\n' +
' */\n'
},
# open the test server in a browser
open: {
server: {
url: 'http://localhost:<%= connect.options.port %>'
}
},
# uglify the js file after it has been complied by coffee
uglify: {
options: {
banner: '<%= meta.banner %>',
report: 'gzip',
preserveComments: false
}
build: {
src: 'dist/angular-servicestack-<%= pkg.version %>.js',
dest: 'dist/angular-servicestack-<%= pkg.version %>-min.js'
}
},
}
grunt.registerTask 'build', [
'clean:build'
,'coffee:build'
,'concat:build'
,'uglify:build'
]
grunt.registerTask 'test', [
'clean:test'
,'copy:test'
,'coffee:test'
,'connect:test'
,'karma:unit'
]
# Default task(s).
grunt.registerTask 'default', ['build']