forked from Esri/esri-leaflet-geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
206 lines (187 loc) · 5.5 KB
/
Gruntfile.js
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
var fs = require('fs');
module.exports = function(grunt) {
var browsers = grunt.option('browser') ? grunt.option('browser').split(',') : ['PhantomJS'];
var umdHeader = '(function (factory) {\n' +
' // define an AMD module that relies on \'leaflet\'\n' +
' if (typeof define === \'function\' && define.amd) {\n' +
' define([\'leaflet\', \'esri-leaflet\'], function (L, Esri) {\n' +
' return factory(L, Esri);\n' +
' });\n' +
'\n' +
' // define a common js module that relies on \'leaflet\'\n' +
' } else if (typeof module === \'object\' && typeof module.exports === \'object\') {\n' +
' module.exports = factory(require(\'leaflet\'), require(\'esri-leaflet\'));\n' +
' }\n' +
'\n' +
' // define globals if we can find the proper place to attach them to.\n' +
' if(typeof window !== \'undefined\' && window.L && window.L.esri) {\n' +
' factory(L, L.esri);\n' +
' }\n' +
'\n' +
'}(function (L, Esri) {\n';
var umdFooter = '\n\n return EsriLeafletGeocoding;\n'+
'}));\n';
var copyright = '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Environmental Systems Research Institute, Inc.\n' +
'* Apache 2.0 License ' +
'*/\n\n';
var files = [
'src/EsriLeafletGeocoding.js',
'src/Tasks/**/*.js',
'src/Services/**/*.js',
'src/Controls/**/*.js',
'src/Providers/**/*.js'
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: {
src: [
'src/**/*.js'
]
}
},
concat: {
options: {
sourceMap: true,
separator: '\n\n',
banner: copyright + umdHeader,
footer: umdFooter
},
js: {
src: files,
dest: 'dist/esri-leaflet-geocoder-src.js'
},
css: {
options: {
banner: '',
footer: ''
},
src: [
'src/esri-leaflet-geocoder.css'
],
dest: 'dist/esri-leaflet-geocoder-src.css'
}
},
uglify: {
options: {
wrap: false,
mangle: {
except: ['L']
},
preserveComments: 'some',
report: 'gzip',
banner: copyright + umdHeader,
footer: umdFooter,
sourceMap: true,
},
dist: {
files: {
'dist/esri-leaflet-geocoder.js': files
}
}
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'src/',
src: ['img/*.{png,jpg,gif}'],
dest: 'dist/'
}]
}
},
cssmin: {
main: {
options: {
wrap: false,
preserveComments: 'some',
report: 'gzip'
},
files: {
'dist/esri-leaflet-geocoder.css': [
'dist/esri-leaflet-geocoder-src.css'
]
}
}
},
s3: {
options: {
key: '<%= aws.key %>',
secret: '<%= aws.secret %>',
bucket: '<%= aws.bucket %>',
access: 'public-read',
headers: {
// 1 Year cache policy (1000 * 60 * 60 * 24 * 365)
"Cache-Control": "max-age=630720000, public",
"Expires": new Date(Date.now() + 63072000000).toUTCString()
}
},
dev: {
upload: [
{
src: 'dist/*',
dest: 'esri-leaflet-geocoder/<%= pkg.version %>/'
},
{
src: 'dist/img/*',
dest: 'esri-leaflet-geocoder/<%= pkg.version %>/img'
}
]
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
run: {
reporters: ['progress'],
browsers: browsers
},
coverage: {
reporters: ['progress', 'coverage'],
browsers: browsers,
preprocessors: {
'src/**/*.js': 'coverage'
}
},
watch: {
singleRun: false,
autoWatch: true,
browsers: browsers
}
},
releaseable: {
release: {
options: {
remote: 'upstream',
dryRun: grunt.option('dryRun') ? grunt.option('dryRun') : false,
silent: false
},
src: ['dist/**/*']
}
}
});
var awsExists = fs.existsSync(process.env.HOME + '/esri-leaflet-s3.json');
if (awsExists) {
grunt.config.set('aws', grunt.file.readJSON(process.env.HOME + '/esri-leaflet-s3.json'));
}
grunt.registerTask('test', 'karma:run');
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['jshint', 'concat', 'uglify', 'imagemin', 'cssmin']);
grunt.registerTask('prepublish', ['concat', 'uglify', 'imagemin', 'cssmin']);
grunt.registerTask('release', ['releaseable', 's3']);
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('grunt-releaseable');
};