-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
119 lines (102 loc) · 3.08 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
module.exports = (grunt) ->
SERVER_PORT = 8001
APP_DIR = 'app'
DEV_BUILD = 'build/development'
bud = require './lib/bud'
grunt.initConfig
clean:
development: [DEV_BUILD]
copy:
development:
files: [
expand:true
cwd: "#{APP_DIR}/public"
src: ['**']
dest: DEV_BUILD
]
jade: bud.gruntJadeConfig
pages: './pages'
partialsDir: "#{APP_DIR}/partials"
outputDir: DEV_BUILD
coffee:
development:
options:
sourceMap: true
files: [
expand: true
cwd: "coffee"
dest: "#{DEV_BUILD}/js"
src: "#{APP_DIR}/**/*.coffee"
ext: ".js"
]
sass:
development:
files: [
src: '#{APP_DIR}/sass/main.scss'
dest: "#{DEV_BUILD}/css/main.css"
]
connect:
server:
options:
hostname: ''
port: SERVER_PORT
middleware: (connect, options) -> [
connect.compress()
connect.static(DEV_BUILD)
]
watch:
jade:
files: ["#{APP_DIR}/templates/*.jade", "#{APP_DIR}/partials/**/*.jade"]
tasks: ['jade']#, 'templates']
coffee:
files: "#{APP_DIR}/coffee/**/*.coffee"
tasks: 'coffee'
sass:
files: "#{APP_DIR}/sass/**/*.scss"
tasks: 'sass'
simplemocha:
options:
ignoreLeaks: false,
reporter: 'spec'
all:
src: 'test/**/*.coffee'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-jade'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-sass'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-simple-mocha'
grunt.registerTask 'templates', 'Compile and concatenate Jade templates for client.', ->
fs = require 'fs'
jade = require 'jade'
hash =
"": "jade/partials"
for templateFileId, templateDir of hash
tmplFileContents = "define(['jade'], function(jade) {\n"
tmplFileContents += 'window.JST = {};\n'
for filename in fs.readdirSync templateDir
path = "#{templateDir}/#{filename}"
contents = jade.compile(
fs.readFileSync(path, 'utf8'), { client: true, compileDebug: false, filename: path }
).toString()
tmplFileContents += "JST['#{filename.split('.')[0]}'] = #{contents};\n"
tmplFileContents += 'return JST;\n'
tmplFileContents += '});\n'
fs.writeFileSync "#{DEV_BUILD}/js/#{if templateFileId then templateFileId + '.' else ''}templates.js", tmplFileContents
grunt.registerTask 'test', 'Run the tests', ->
Browser = require 'zombie'
Browser.default.site = "amitair.local:3000"
grunt.config.data.connect.server.options.port = 3000
grunt.task.run ['connect', 'simplemocha']
grunt.registerTask 'default', [
'clean',
'copy',
'jade',
# 'templates',
'coffee',
# 'sass',
'connect'
'watch'
]