forked from amw/jpeg_camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
94 lines (89 loc) · 3 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
module.exports = (grunt) ->
banner =
"/*! JpegCamera <%= pkg.version %> | " +
"<%= grunt.template.today('yyyy-mm-dd') %>\n" +
" (c) 2013 Adam Wrobel\n" +
" <%= pkg.homepage %> */\n"
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
coffee:
compile:
options:
join: true
files:
"dist/jpeg_camera.js": [
"src/jpeg_camera.coffee",
"src/jpeg_camera_html5.coffee",
"src/jpeg_camera_flash.coffee",
"src/snapshot.coffee",
"src/stats.coffee"
]
"dist/jpeg_camera_no_flash.js": [
"src/jpeg_camera.coffee",
"src/jpeg_camera_html5.coffee",
"src/snapshot.coffee",
"src/stats.coffee"
]
uglify:
minify:
options:
banner: banner
files:
"dist/jpeg_camera.min.js": ["dist/jpeg_camera.js"]
"dist/jpeg_camera_no_flash.min.js": ["dist/jpeg_camera_no_flash.js"]
concat:
add_banner:
options:
banner: banner
files:
"dist/jpeg_camera.js": ["dist/jpeg_camera.js"]
"dist/jpeg_camera_no_flash.js": ["dist/jpeg_camera_no_flash.js"]
with_dependencies:
options:
banner: "/*! SWFObject + Canvas-to-Blob + JpegCamera */\n\n"
files:
"dist/jpeg_camera_with_dependencies.min.js": [
"dist/swfobject.min.js",
"dist/canvas-to-blob.min.js",
"dist/jpeg_camera.min.js"
]
exec:
swf:
cmd: "mxmlc -static-link-runtime-shared-libraries " +
"-output dist/jpeg_camera.swf src/as3/JpegCamera.as"
rm_doc:
cmd: "rm -fr doc"
doc:
cmd: "PATH=\"$(npm bin):$PATH\" codo; " +
"cp index.html doc/index.html"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-exec"
grunt.registerTask "rubygem", "Prepare gem for Ruby on Rails apps", ->
js_files = [
"jpeg_camera.js",
"jpeg_camera.min.js",
"jpeg_camera_no_flash.js",
"jpeg_camera_no_flash.min.js",
"canvas-to-blob.js",
"canvas-to-blob.min.js",
"swfobject.js",
"swfobject.min.js"
]
for file in js_files
grunt.file.copy "dist/#{file}",
"vendor/assets/javascripts/jpeg_camera/#{file}"
grunt.file.copy "dist/jpeg_camera.swf",
"app/assets/images/jpeg_camera/jpeg_camera.swf"
grunt.file.copy "dist/shutter.mp3",
"app/assets/audios/jpeg_camera/shutter.mp3"
grunt.file.copy "dist/shutter.ogg",
"app/assets/audios/jpeg_camera/shutter.ogg"
grunt.registerTask "js",
["coffee", "uglify", "concat:add_banner", "concat:with_dependencies"]
grunt.registerTask "swf", ["exec:swf"]
grunt.registerTask "doc", ["exec:rm_doc", "exec:doc"]
grunt.registerTask "dist", ["js", "swf", "rubygem"]
grunt.registerTask "all", ["dist", "doc"]
grunt.registerTask "default", ["all"]