forked from apache/cordova-registry-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
142 lines (133 loc) · 4.17 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
'use strict';
module.exports = function(grunt) {
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
config:grunt.file.readJSON('config.json'),
watch: {
reloadServer: {
options: {
livereload: true
},
files: ['attachments/*.html', 'attachments/partials/**/*.html', 'attachments/css/styles.css', 'attachments/js/**/*.js'],
tasks: ['shell:reloadServer']
},
stylesheets: {
files: ['attachments/css/**/*.less'],
tasks: ['less']
}
},
shell: {
options: {
stdout: true
},
reloadServer: {
command: 'couchapp push app.js http://localhost:5984/registry'
},
cloudant: {
command: 'couchapp push app.js http://<%= config.cloudant.username %>:<%= config.cloudant.password %>@<%= config.cloudant.url %>/registry'
},
iriscouch: {
command: 'couchapp push app.js http://<%= config.iriscouch.username %>:<%= config.iriscouch.password %>@<%= config.iriscouch.url %>/registry'
}
},
less: {
development: {
options: {
paths: ["attachments/css"]
},
files: {
"attachments/css/styles.css": "attachments/css/styles.less"
}
},
},
connect: {
options: {
port: 5000,
hostname: 'localhost'
},
localRegistry:{
proxies: [{
context: '/',
host: 'localhost',
port:5984,
https: false,
changeOrigin: false,
rewrite:{
'^/(.*)$':'/registry/_design/ui/_rewrite/$1'
}
}]
},
develop: {
options: {
middleware: function (connect, options) {
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
// Setup the proxy
var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];
// Serve static files.
options.base.forEach(function(base) {
middlewares.push(connect.static(base));
});
// Make directory browse-able.
var directory = options.directory || options.base[options.base.length - 1];
middlewares.push(connect.directory(directory));
return middlewares;
},
}
}
},
preprocess: {
livereloadout: {
options: {
context: {
PRODUCTION: true
}
},
files: {
'attachments/index.html' : 'attachments/index.html'
}
}
},
copy: {
after: {
src: './tmp/index.html',
dest: 'attachments/index.html'
},
before: {
src: 'attachments/index.html',
dest: './tmp/index.html'
}
}
});
//load all of the grunt tasks
require('load-grunt-tasks')(grunt);
grunt.registerTask('server', function (target) {
grunt.task.run([
'configureProxies:localRegistry',
'connect:develop',
'shell:reloadServer',
'watch'
]);
});
grunt.registerTask('cloudant', function (target) {
grunt.task.run([
'less',
'copy:before', //Copy index.html to tmp, to save the preprocess directives
'preprocess', //Preprocess out the livereload script.
'shell:cloudant',
'copy:after' //Copy index.html back to attachments, with the preprocess directives as seved.
]);
});
grunt.registerTask('iriscouch', function (target) {
grunt.task.run([
'less',
'copy:before', //Copy index.html to tmp, to save the preprocess directives
'preprocess', //Preprocess out the livereload script.
'shell:iriscouch',
'copy:after' //Copy index.html back to attachments, with the preprocess directives as seved.
]);
});
grunt.registerTask('pre', ['copy:before', 'preprocess', 'copy:after']);
};