-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGruntfile.js
142 lines (125 loc) · 5.01 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
/**
* Copyright (C) 2013-2014 Christophe Rosset <[email protected]> - https://github.com/topheman/PanoramaSensorsViewer
*
* Released under MIT License :
* https://github.com/topheman/PanoramaSensorsViewer/blob/master/LICENSE
*/
/**
* Tou know grunt ? It's great ! Two things :
* - npm install (will install the node packages needed)
* - npm install grunt-cli -g (if you don't have it already)
* - grunt server (will start you a local server so that you can test)
*/
module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
var PanoramaSensorsViewerVersion = require('./package.json').version,
gruntSpecificOptions;
try{
gruntSpecificOptions = grunt.file.readJSON('./grunt.options.json');//specific options meant to be split from the hard code of the GruntFile.js
}
catch(e){
grunt.log.error("No grunt.options.json file find (you will need it for ftp-deploy)");
}
// Configure Grunt
grunt.initConfig({
// grunt-contrib-connect will serve the files of the project
// on specified port and hostname
connect: {
debug: {
options: {
port: 9002,
hostname: "0.0.0.0",
keepalive: true,
base: "src"
}
},
release: {
options: {
port: 9002,
hostname: "0.0.0.0",
keepalive: true,
base: "release"
}
}
},
// grunt-open will open your browser at the project's URL
open: {
debug: {
path: 'http://localhost:<%= connect.debug.options.port%>/'
},
release: {
path: 'http://localhost:<%= connect.release.options.port%>/'
}
},
//this part is for building
clean: {
//clean all before any build
all: {
src : ['release']
},
"after-build" : {
src : [
'release/googleAnalyticsScriptTag.html'
]
}
},
copy:{
release:{
files:[
{expand: true, cwd: 'src/', src: ['**'], dest: 'release/'}
]
}
},
"git-rev-parse": {
panoramaSensorsViewerRevision: {
options: {
prop: 'PanoramaSensorsViewerRevision',
number: 8
}
}
},
//https://github.com/jsoverson/preprocess + https://npmjs.org/package/grunt-preprocess
preprocess: {
options:{
context:{
"PanoramaSensorsViewerVersion" : PanoramaSensorsViewerVersion,
"PanoramaSensorsViewerRevision" : '<%= grunt.config.get("PanoramaSensorsViewerRevision") %>',
"PanoramaSensorsViewerVersionAndRevision" : 'v'+PanoramaSensorsViewerVersion+' - r.<%= grunt.config.get("PanoramaSensorsViewerRevision") %>'
}
},
"process-html" : {
files : {
'release/index.html' : 'src/index.html',
'release/demo.basic.html' : 'src/demo.basic.html',
'release/demo.controls.html' : 'src/demo.controls.html',
'release/demo.custompanorama.html' : 'src/demo.custompanorama.html',
'release/demo.custompanorama.tiles.html' : 'src/demo.custompanorama.tiles.html',
'release/demo.events.html' : 'src/demo.events.html',
'release/demo.deviceorientationhelper.html' : 'src/demo.deviceorientationhelper.html',
'release/test.bug.android.firefox.html' : 'src/test.bug.android.firefox.html',
}
}
}
});
if(gruntSpecificOptions){
grunt.config("ftp-deploy",{
release: {
auth: {
host: gruntSpecificOptions["ftp-deploy"].release.host,
port: gruntSpecificOptions["ftp-deploy"].release.port,
authKey: 'key1'
},
src: 'release',
dest: gruntSpecificOptions["ftp-deploy"].release.dest,
exclusions: ['release/build.txt']
}
});
grunt.registerTask('deploy', ['ftp-deploy:release']);
}
grunt.registerTask('server', ['open:debug', 'connect:debug']);
grunt.registerTask('default', ['open:debug', 'connect:debug']);
grunt.registerTask('getGitRevisionNumbers',['git-rev-parse']);
grunt.registerTask('build', ['clean:all','copy:release','getGitRevisionNumbers','preprocess:process-html','clean:after-build']);
grunt.registerTask('server-release', ['open:release', 'connect:release']);
};