-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
136 lines (119 loc) · 4.02 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
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
coffee:
options:
bare: true
test:
files: ['build/<%= pkg.name %>.<%= pkg.version %>.js': 'source/<%= pkg.name %>.<%= pkg.version %>.coffee', 'test/temp_test_spec.js': 'test/*.coffee']
dev:
files: 'build/<%= pkg.name %>.<%= pkg.version %>.js': 'source/<%= pkg.name %>.<%= pkg.version %>.coffee'
coffeelint:
all: "source/*.coffee"
clean:
build: 'build/*',
test: ['test/*.js', 'test/coverage_report/']
uglify:
options:
banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today(\'yyyy-mm-dd h:MM:ss TT Z\') %> */\n'
mangle:
except: 'StorageJS'
dev:
files:
'build/<%= pkg.name %>.<%= pkg.version %>.min.js': 'build/<%= pkg.name %>.<%= pkg.version %>.js'
prod:
files:
'public/js/<%= pkg.name %>.<%= pkg.version %>.min.js': 'build/<%= pkg.name %>.<%= pkg.version %>.js'
jshint:
build: 'build/<%= pkg.name %>.<%= pkg.version %>.js'
test: 'test/*.js'
compress:
main:
options:
mode: 'gzip'
files: [
expand: true
src: ['build/*.min.js']
dest: ''
ext: '.<%= pkg.version %>.min.gz.js'
]
jasmine:
src: 'build/<%= pkg.name %>.<%= pkg.version %>.js'
options:
specs: 'test/*.js'
# template: require 'grunt-template-jasmine-istanbul'
# templateOptions:
# coverage: 'test/coverage/coverage.json'
# report: 'test/coverage_report/'
s3:
options:
key: process.env.AWS_KEY
secret: process.env.AWS_SECRET
bucket: process.env.AWS_S3_BUCKET
access: 'public-read'
prod:
upload:
[
src: "build/<%= pkg.name %>.<%= pkg.version %>.min.gz.js"
dest: "<%= pkg.name %>.<%= pkg.version %>.min.gz.js"
headers:
"Content-Encoding": "gzip"
"Content-Type": "text/javascript"
]
cloudfront:
options:
region: 'us-east-1'
distributionId: process.env.AWS_CF_DIST_ID
credentials:
accessKeyId: process.env.AWS_KEY
secretAccessKey: process.env.AWS_SECRET
invalidate:
Paths:
Quantity: 1
Items: ['/<%= pkg.name %>.<%= pkg.version %>.min.gz.js']
CallerReference: Math.random().toString()
watch:
coffee:
files: 'source/*.coffee',
tasks: 'default'
imagemin:
dev:
options:
optimizationLevel: 3
files: ['public/img.jpg': 'source/img.jpg']
prod:
options:
optimizationLevel: 7
files: ['public/img_prod.jpg': 'source/img.jpg']
less:
dev:
files: ["public/app.css": "source/app.less"]
cssmin:
dev:
files: ["public/app.min.css": "public/app.css"]
htmlmin:
options:
removeComments: true,
collapseWhitespace: true
dev:
files: ["public/index.min.html": "public/index.html"]
# Load the task plugins:
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-contrib-nodeunit'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-compress'
grunt.loadNpmTasks 'grunt-contrib-jasmine'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-s3'
grunt.loadNpmTasks 'grunt-cloudfront'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-imagemin'
grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-contrib-htmlmin'
# Default task(s).
grunt.registerTask 'default', ['coffeelint', 'coffee', 'jshint', 'uglify', 'compress']
grunt.registerTask 'test', ['coffee:test', 'jshint:test', 'jasmine']
grunt.registerTask 'deploy', ['default', 'test', 's3', 'cloudfront']