-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathGruntfile.coffee
More file actions
183 lines (153 loc) · 5.13 KB
/
Gruntfile.coffee
File metadata and controls
183 lines (153 loc) · 5.13 KB
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
170
171
172
173
174
175
176
177
178
179
180
module.exports = (grunt)->
###############################################################
# Constants
###############################################################
PROFILE = grunt.option('profile') || 'dev'
SRC_DIR = 'src'
SRC_TEST_DIR = "#{SRC_DIR}/test"
SRC_PROFILES_DIR = "#{SRC_DIR}/profiles"
CURRENT_PROFILE_DIR = "#{SRC_PROFILES_DIR}/#{PROFILE}"
TARGET_DIR = 'target'
BUILD_DIR = "#{TARGET_DIR}/build"
BUILD_MAIN_DIR = "#{BUILD_DIR}/main"
STAGE_DIR = "#{TARGET_DIR}/stage"
STAGE_APP_DIR = "#{STAGE_DIR}/app"
STAGE_TEST_DIR = "#{STAGE_DIR}/test"
BUILD_TEST_DIR = "#{BUILD_DIR}/test"
# index.html is special, since it should be moved out of the index
# view and into the root
SRC_INDEX_HTML = "#{STAGE_APP_DIR}/index/index.html"
DEST_INDEX_HTML = "#{BUILD_MAIN_DIR}/index.html"
###############################################################
# Config
###############################################################
grunt.initConfig
clean:
main:
src: TARGET_DIR
copy:
# Copy all non-profile to the stage dir. Stage dir allows
# us to override
# non-profile-specific code w/ the profile defined on the
# cmd line (or 'dev' by default)
stage:
files:[
{
expand: true
cwd: "#{SRC_DIR}/main"
src: '**'
dest: STAGE_DIR
}
]
# override staging dir w/ profile-specific files
profiles:
files: [
{
expand: true
cwd: CURRENT_PROFILE_DIR
src: '**'
dest: STAGE_DIR
}
]
# copies all files from staging to the build dir that
# do not need any further processing
static:
files: [
{
src: SRC_INDEX_HTML
dest: DEST_INDEX_HTML
}
{
expand: true
cwd: STAGE_APP_DIR
src: [
'**/*.{html,jpg,png,gif}', "!{SRC_INDEX_HTML}"
]
dest: BUILD_MAIN_DIR
}
]
test:
files: [
{
expand: true
cwd: SRC_TEST_DIR
src: ['{lib,config}/**']
dest: BUILD_TEST_DIR
}
]
concat:
app_css:
src: "#{STAGE_APP_DIR}/**/*.css"
dest: "#{BUILD_MAIN_DIR}/style/app.css"
lib_css:
src: "#{STAGE_DIR}/lib/**/*.css"
dest: "#{BUILD_MAIN_DIR}/style/lib.css"
lib_js:
src: "#{STAGE_DIR}/lib/**/*.js"
dest: "#{BUILD_MAIN_DIR}/js/lib.js"
coffee:
app:
src: "#{STAGE_APP_DIR}/**/*.coffee"
dest: "#{BUILD_MAIN_DIR}/js/app.js"
test:
src: "#{SRC_TEST_DIR}/**/*.coffee"
dest: "#{BUILD_TEST_DIR}/js/lib.js"
coffeelint:
app: ["#{STAGE_APP_DIR}/**/*.coffee"]
tests:
files: {
src: ["#{SRC_TEST_DIR}/**/*.coffee"]
}
options:
'no_trailing_whitespace':
'level': 'error'
uglify:
lib_js:
src: "#{BUILD_MAIN_DIR}/js/lib.js"
dest: "#{BUILD_MAIN_DIR}/js/lib.js"
app_js:
src: "#{BUILD_MAIN_DIR}/js/app.js"
dest: "#{BUILD_MAIN_DIR}/js/app.js"
cssmin:
lib_css:
src: "#{BUILD_MAIN_DIR}/style/lib.css"
dest: "#{BUILD_MAIN_DIR}/style/lib.css"
app_css:
src: "#{BUILD_MAIN_DIR}/style/app.css"
dest: "#{BUILD_MAIN_DIR}/style/app.css"
connect:
server:
options:
base: BUILD_MAIN_DIR
regarde:
build:
options:
base: BUILD_MAIN_DIR
files: ["#{SRC_DIR}/**/*.{css,coffee,js,html}"]
tasks: ['build']
# Note, disabling this until
# https://github.com/mklabs/tiny-lr/issues/8 is resolved
#
# livereload:
# files: ["#{BUILD_DIR}/**/*.{css,js,html}"]
# tasks: ['livereload']
##############################################################
# Dependencies
###############################################################
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-cssmin')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-livereload')
grunt.loadNpmTasks('grunt-regarde')
grunt.loadNpmTasks('grunt-coffeelint')
###############################################################
# Alias tasks
###############################################################
grunt.registerTask('build', ['copy','concat','coffeelint','coffee'])
grunt.registerTask('watcher', ['livereload-start', 'connect', 'regarde'])
grunt.registerTask('dist', ['build','uglify','cssmin'])
grunt.registerTask('default', ['clean','build','watcher'])