-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrunt.coffee
148 lines (115 loc) · 4.02 KB
/
grunt.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
utils = require './grunt-utils'
NPM_TASKS = [
'grunt-coffee'
'grunt-compass'
'grunt-contrib-copy'
'grunt-contrib-clean'
'grunt-jade'
]
TASKS = [
'grunt-connect'
'grunt-config-context'
]
module.exports = (grunt) ->
_ = grunt.utils._
NPM_TASKS.forEach (task) ->
grunt.loadNpmTasks task
TASKS.forEach (task) ->
utils.loadTask grunt, './grunt-tasks', task
# Should be called init tasks... it would make more sense.
grunt.initConfig
config:
build_directory: 'build'
tmp_directory: 'tmp'
# Remove some directories
clean:
build_directory: '<%= config.build_directory %>'
tmp_directory: '<%= config.tmp_directory %>'
# Compile the coffee files
coffee:
app:
src: 'src/scripts/app/**/*.coffee'
dest: '<%= config.build_directory %>/assets/js/app'
options:
base_path: 'src/scripts/app'
preserve_dirs: true
bare: false
libs:
src: 'src/scripts/libs/**/*.coffee'
dest: '<%= config.build_directory %>/assets/js/libs'
options:
base_path: 'src/scripts/libs'
preserve_dirs: true
bare: false
# Compile the jade files
jade:
app:
# FIXME: Can't get folder exclusion syntax to work...
src: 'src/jade/**/*.jade'
dest: '<%= config.build_directory %>'
options:
client: false
pretty: true
compileDebug: true
# Copy some assets...
copy:
#css_libs:
# files: '<%= config.build_directory %>/assets/css/libs/': 'src/styles/libs/**'
js_libs:
files: '<%= config.build_directory %>/assets/js/libs/': 'src/scripts/libs/**'
images:
files: '<%= config.build_directory %>/assets/images/': 'src/images/**'
# CSS Compass compilation
compass:
dev:
src: 'src/styles'
dest: '<%= config.build_directory %>/assets/css'
images: 'src/images'
fonts: 'src/fonts'
relativeassets: true
linecomments: true
# This should enable source maps for sass, but it doesn't work for me.
# debugsass: true
# outputstyle: 'nested'
# Create HTTP Server on a directory
connect:
debug: true
port: 8000
base: ->
grunt.config.get 'config.build_directory'
middleware: (grunt, connect, base) -> [
# Allows CORS to all domains (don't use this in production!)
(request, response, next) ->
response.setHeader 'Access-Control-Allow-Origin', '*'
response.setHeader 'Access-Control-Allow-Headers', 'Accept,Accept-Version,Content-Length,Content-MD5,Content-Type,Date,X-Api-Version,Origin,X-Requested-With'
response.setHeader 'Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'
next()
# Serve static files
connect.static base
# Make empty directories browsable. (overkill?)
connect.directory base
]
# Rebuild everything when something changes
watch:
files: [
'grunt.coffee'
'grunt.js'
'src/**/*'
]
tasks: 'build'
utils.registerGruntTask grunt, 'build', [
'clean:build_directory'
'coffee'
'jade'
'compass'
'copy'
'clean:tmp_directory'
]
utils.registerGruntTask grunt, 'run', [
'default'
'connect'
'watch'
]
utils.registerGruntTask grunt, 'default', [
'build'
]