-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
169 lines (128 loc) · 4.96 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
module.exports = (grunt) ->
# paths setup - separate as some modules dont process templates correctly
paths =
# coffescript sources
coffee_dir: 'coffee'
coffee_src: 'coffee/**/*.coffee'
# javascript sources
js_dir: 'js'
js_src: 'js/src/**/*.js'
js_specs: 'js/test/**/*.spec.js'
# build directory
build_dir: 'build'
# minified target name
minified: 'build/athena.lib.min.js'
# jasmine test page to render
test_page: 'static/tests.html'
# libraries to load in the frontend
frontend_libs: [
'lib/closure/library/closure/goog/base.js' # for dependencies
'lib/mixpanel/mixpanel.js' # for analytics
'node_modules/jquery-browser/lib/jquery.js' # for dom manipulation
'node_modules/underscore/underscore.js' # for utilities
'node_modules/backbone/backbone.js' # for mvc apps
'node_modules/grunt-jasmine-spec-server/lib/bootstrap/js/bootstrap.min.js'
'node_modules/marked/lib/marked.js' # for rendering docs
]
# YOU SHOULD NOT NEED TO MODIFY BELOW THIS LINE.
# you may have to... if things break...
# google closure paths
paths.closure =
# dependencies file
deps: "#{paths.js_dir}/deps.js"
# main entry point
main: "#{paths.js_dir}/src/lib.js"
# output file for the compiler
compiled: paths.minified
# root of the sources that closure should use
# silliness. because depswriter.py uses paths relative to closure library
root_with_prefix: "'#{paths.js_dir} ../../../../../#{paths.js_dir}'"
# path to library. this should be a submodule.
library: 'lib/closure/library'
# path to compiler. this should be a symlink (or the actual jar).
compiler: 'lib/closure/compiler.jar'
# jasmine paths
paths.jasmine =
# lib to include before sources (e.g. jquery, underscore, etc).
lib: paths.frontend_libs
# src to include. use closure deps and main entry point
src: [paths.closure.deps, paths.closure.main]
# specs to include.
specs: paths.js_specs
# view to render
view: paths.test_page
# Project configuration.
grunt.initConfig
# load package information
pkg: grunt.file.readJSON 'package.json'
# task to compile coffeescript into javascript
coffee:
default:
src: paths.coffee_src
dest: paths.js_dir
options:
preserve_dirs: true
base_path: paths.coffee_dir
# task to compute file dependencies (closure)
closureDepsWriter:
default:
closureLibraryPath: paths.closure.library
options:
output_file: paths.closure.deps
root_with_prefix: paths.closure.root_with_prefix
# task to compile code into a minified file (closure)
closureCompiler:
default:
js: paths.js_src
closureCompiler: paths.closure.compiler
checkModified: true
options:
# compilation_level: 'ADVANCED_OPTIMIZATIONS',
# externs: ['path/to/file.js', '/source/**/*.js'],
# define: ["'goog.DEBUG=false'"],
# warning_level: 'verbose',
# jscomp_off: ['checkTypes', 'fileoverviewTags'],
# summary_detail_level: 3,
# formatting: 'PRETTY_PRINT'
js_output_file: paths.closure.compiled
output_wrapper: '"(function(){%output%}).call(this);"'
# task to run jasmine tests through the commandline via phantomjs
jasmine:
# concat because jasmine-runner doesnt support libs (before srcs)
src: [].concat(paths.jasmine.lib, paths.jasmine.src)
specs: paths.jasmine.specs
# task to run jasmine tests in a webserver
jasmineSpecServer:
lib: paths.jasmine.lib
src: paths.jasmine.src
specs: paths.jasmine.specs
view: paths.jasmine.view
# task to watch sources for changes and recompile during development
watch:
files: paths.coffee_src
tasks: 'sources' # or 'test', or 'testserver' :)
# task to run shell commands
exec:
# create the build directory. closure errors out if it isn't there...
mkbuild: command: "mkdir -p #{paths.build_dir}"
# task to clean up directories
clean:
# the generated javascript sources
js: paths.js_dir
# the generated build dir
build: paths.build_dir
# the generated jasmine-runner tester file
test: ['_SpecRunner.html']
# Load tasks
grunt.loadNpmTasks 'grunt-exec'
grunt.loadNpmTasks 'grunt-coffee'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-closure-tools'
grunt.loadNpmTasks 'grunt-jasmine-runner'
grunt.loadNpmTasks 'grunt-jasmine-spec-server'
# Register tasks
grunt.registerTask 'compile', ['coffee', 'exec:mkbuild', 'closureCompiler']
grunt.registerTask 'sources', ['coffee', 'closureDepsWriter']
grunt.registerTask 'test', ['sources', 'jasmine', 'clean:test']
grunt.registerTask 'server', ['sources', 'jasmineSpecServer', 'watch']
grunt.registerTask 'default', ['compile']