-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
119 lines (100 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
fs = require 'fs'
jade = require 'jade'
module.exports = (grunt) ->
# load external grunt tasks
grunt.loadNpmTasks 'grunt-express'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-sass'
grunt.loadNpmTasks 'grunt-contrib-jade'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-requirejs'
grunt.loadNpmTasks 'grunt-env'
DEV_PATH = "app"
PRODUCTION_PATH = "dist"
grunt.initConfig
clean:
development: "#{PRODUCTION_PATH}"
copy:
development:
files: [
{ expand: true, cwd: "#{DEV_PATH}/public", src:['**'], dest: PRODUCTION_PATH }
]
express:
test:
options:
server: './server/server'
port: 5000
development:
options:
server: './server/server'
port: 3000
jade:
development:
options:
pretty: false
files: [
{
src: "#{DEV_PATH}/index.jade"
dest: "#{PRODUCTION_PATH}/index.html"
}
]
sass:
development:
files: [
expand: true
cwd: "#{DEV_PATH}/styles"
src: ['*.sass']
dest: "#{PRODUCTION_PATH}/styles"
ext: ".css"
]
coffee:
development:
options:
sourceMap: false
files: [
expand: true
cwd: "#{DEV_PATH}/coffee"
dest: "#{PRODUCTION_PATH}/js"
src: ["*.coffee", "**/*.coffee"]
ext: ".js"
]
watch:
coffee:
files: ["#{DEV_PATH}/coffee/*.coffee", "#{DEV_PATH}/coffee/*/*.coffee","#{DEV_PATH}/coffee/*/*/*.coffee"]
tasks: 'coffee:development'
sass:
files: ["{DEV_PATH}/styles/*.sass", "#{DEV_PATH}/styles/**/*.sass"]
tasks: 'sass:development'
jade:
files: ["#{DEV_PATH}/index.jade", "#{DEV_PATH}/partials/*.jade", "#{DEV_PATH}/partials/**/*.jade"]
tasks: ['jade:development', 'clientTemplates']
grunt.registerTask 'clientTemplates', 'Compile and concatenate Jade templates for client.', ->
templates =
'text': "#{DEV_PATH}/partials/text.jade"
"InfoWindow": "#{DEV_PATH}/partials/info_window.jade"
tmplFileContents = "var JST = (function() {\n"
tmplFileContents += 'var JST = {};\n'
for namespace, filename of templates
path = "#{__dirname}/#{filename}"
contents = jade.compile(
fs.readFileSync(path, 'utf8'), { client: true, compileDebug: false, filename: path }
).toString()
tmplFileContents += "JST['#{namespace}'] = #{contents};\n"
tmplFileContents += 'return JST;\n'
tmplFileContents += '})();\n'
fs.writeFileSync "#{PRODUCTION_PATH}/js/templates.js", tmplFileContents
grunt.registerTask 'development', [
'clean:development'
'copy:development'
'coffee:development'
'sass:development'
'jade:development'
'clientTemplates'
]
grunt.registerTask 'default', [
'development'
'express:development'
'watch'
]