forked from Addepar/ember-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
163 lines (146 loc) · 5.41 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
# Gruntfile courtesy of trek (https://github.com/trek/)
# ember-todos-with-build-tools-tests-and-other-modern-conveniences
module.exports = (grunt) ->
# env could be 'dev' or 'prod'
env = grunt.option("env") or "dev"
grunt.initConfig
clean:
target: ['build', 'dist' , 'gh_pages']
uglify:
"dist/ember-widgets.min.js": "dist/ember-widgets.js"
coffee:
srcs:
options:
bare: true
expand: true
cwd: "src/"
src: [ "**/*.coffee" ]
dest: "build/src/"
ext: ".js"
app:
options:
bare: true
expand: true
cwd: "app/"
src: [ "**/*.coffee" ]
dest: "build/app/"
ext: ".js"
emberTemplates:
options:
templateName: (sourceFile) ->
sourceFile.replace(/src\/templates\//, '')
.replace(/app\/templates\//, '')
'build/src/templates.js': ["src/templates/**/*.hbs"]
'build/app/templates.js': ["app/templates/**/*.hbs"]
neuter:
options:
includeSourceURL: no
"dist/ember-widgets.js": "build/src/ember_widgets.js"
"gh_pages/app.js": "build/app/app.js"
less:
development:
options:
yuicompress: env isnt "dev"
files:
"dist/ember-widgets.css": "src/css/ember-widgets.less"
app:
options:
yuicompress: env isnt "dev"
files:
"gh_pages/css/app.css": "app/assets/css/app.less"
###
Copy build/app/assets/css into gh_pages/asset and other assets from app
###
copy:
gh_pages:
files: [
{src: ['dist/ember-widgets.css'], dest: 'gh_pages/css/ember-widgets.css'},
{src: ['app/index.html'], dest: 'gh_pages/index.html'},
{expand: true, flatten: true, cwd: 'dependencies/', src: ['**/*.js'], dest: 'gh_pages/lib'},
{expand: true, flatten: true, cwd: 'dependencies/', src: ['**/*.css'], dest: 'gh_pages/css'},
{expand: true, cwd: 'dependencies/font-awesome/fonts/', src: ['**'], dest: 'gh_pages/font'},
{expand: true, cwd: 'app/assets/font/', src: ['**'], dest: 'gh_pages/font'},
{expand: true, cwd: 'app/assets/img/', src: ['**'], dest: 'gh_pages/img'}
]
###
Watch files for changes.
Changes in dependencies/ember.js or src javascript
will trigger the neuter task.
Changes to any templates will trigger the emberTemplates
task (which writes a new compiled file into dependencies/)
and then neuter all the files again.
###
watch:
grunt:
files: [ "Gruntfile.coffee" ]
tasks: [ "default" ]
src:
files: [ "src/**/*.coffee"]
tasks: [ "coffee:srcs", "neuter" ]
src_handlebars:
files: [ "src/**/*.hbs" ]
tasks: [ "emberTemplates", "neuter" ]
app:
files: [ "app/**/*.coffee", "dependencies/**/*.js" ]
tasks: [ "coffee:app", "neuter" ]
app_handlebars:
files: [ "app/**/*.hbs"]
tasks: [ "emberTemplates", "neuter" ]
less:
files: [ "src/**/*.less", "src/**/*.css",
"dependencies/**/*.less", "dependencies/**/*.css",
"app/assets/**/*.less", "app/assets/**/*.css" ]
tasks: ["less", "copy"]
copy:
files: [ "app/index.html" ]
tasks: [ "copy" ]
###
Runs all .html files found in the test/ directory through PhantomJS.
Prints the report in your terminal.
###
qunit:
all: [ "test/**/*.html" ]
###
Reads the projects .jshintrc file and applies coding
standards. Doesn't lint the dependencies or test
support files.
###
jshint:
all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!dependencies/*.*', '!test/support/*.*']
options:
jshintrc: ".jshintrc"
###
Find all the <whatever>_test.js files in the test folder.
These will get loaded via script tags when the task is run.
This gets run as part of the larger 'test' task registered
below.
###
build_test_runner_file:
all: [ "test/**/*_test.js" ]
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-jshint"
grunt.loadNpmTasks "grunt-contrib-qunit"
grunt.loadNpmTasks "grunt-neuter"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-ember-templates"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-less"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-contrib-clean"
###
A task to build the test runner html file that get place in
/test so it will be picked up by the qunit task. Will
place a single <script> tag into the body for every file passed to
its coniguration above in the grunt.initConfig above.
###
grunt.registerMultiTask "build_test_runner_file", "Creates a test runner file.", ->
tmpl = grunt.file.read("test/support/runner.html.tmpl")
renderingContext = data:
files: @filesSrc.map (fileSrc) -> fileSrc.replace "test/", ""
grunt.file.write "test/runner.html", grunt.template.process(tmpl, renderingContext)
grunt.registerTask "build_srcs", [ "coffee:srcs", "emberTemplates", "neuter" ]
grunt.registerTask "build_app", [ "coffee:app", "emberTemplates", "neuter" ]
if env is "dev"
grunt.registerTask "default", [ "build_srcs", "build_app", "less", "copy", "uglify", "watch" ]
else
grunt.registerTask "default", [ "less", "build_srcs", "uglify"]