-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathGruntfile.js
152 lines (137 loc) · 3.91 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
var LOCAL_CONFIG = {
appName: 'local',
appVersion: '1',
hardCodeStripe: true,
stripePublicKey: 'pk_test_g7UBToGvPpJ1xJa8OVsfV7zf',
stripePrivateKey: 'sk_test_sm4iLzUFCeEE4l8uKe4KNDU7',
productionPaypal: false,
};
var DEV_CONFIG = {
appName: 'pure-spring-568',
appVersion: '1',
productionPaypal: false,
};
var STAGING_CONFIG = {
appName: 'mayday-pac',
appVersion: 'staging',
productionPaypal: false,
};
var PROD_CONFIG = {
appName: 'mayday-pac',
appVersion: '1',
productionPaypal: true,
};
var preprocessAppYaml = function(config) {
return {
src : [ 'build/app.yaml' ],
options: { inline : true, context : config }
};
};
var createConfigFile = function(config) {
return {
"build/config.json": function(fs, fd, done) {
fs.writeSync(fd, JSON.stringify(config));
done();
}
};
};
module.exports = function(grunt) {
// configure the tasks
grunt.initConfig({
clean: {
main: {
src: [ 'build' ],
},
},
copy: {
main: {
files: [
{cwd: 'backend/', src: '**', dest: 'build/', expand: true },
{cwd: 'lib/', src: '**', dest: 'build/', expand: true },
{cwd: 'assets/', src: '**', dest: 'build/static/', expand: true },
{cwd: 'jinja_templates', src: '**', dest: 'build/templates/', expand: true },
],
},
},
preprocess: {
local : preprocessAppYaml(LOCAL_CONFIG),
dev: preprocessAppYaml(DEV_CONFIG),
staging: preprocessAppYaml(STAGING_CONFIG),
prod: preprocessAppYaml(PROD_CONFIG),
},
jade: {
compile: {
options: {
data: {
debug: false
}
},
files: [
{cwd: 'markup/', src: '*.jade.j2', dest: 'build/templates/',
expand: true, ext: '.html'},
{cwd: 'markup/', src: '*.jade', dest: 'build/static/', expand: true,
ext: '.html'},
]
}
},
autoprefixer: {
build: {
expand: true,
cwd: 'build/static/css/',
src: [ '*.css' ],
dest: 'build/static/css/'
}
},
shell: {
devserver: {
command: 'dev_appserver.py --skip_sdk_update_check --host 0.0.0.0 --admin_host 0.0.0.0 build/',
options: {
async: true,
},
},
},
"file-creator": {
local: createConfigFile(LOCAL_CONFIG),
dev: createConfigFile(DEV_CONFIG),
staging: createConfigFile(STAGING_CONFIG),
prod: createConfigFile(PROD_CONFIG),
},
watch: {
markup: {
files: 'markup/**',
tasks: [ 'jade' ]
},
copy: {
files: [ '{js/src,resources,assets,templates,backend}/**' ],
tasks: [ 'copy', 'preprocess:local' ]
}
},
});
// load the tasks
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-file-creator');
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-shell-spawn');
// define the tasks
grunt.registerTask(
'build',
'Compiles all of the assets and copies the files to the build directory.',
[ 'clean', 'copy', 'jade']
);
grunt.registerTask(
'local',
'Builds, runs the local dev server, and watches for updates.',
[ 'build', 'preprocess:local', 'file-creator:local',
'shell:devserver', 'watch']
);
grunt.registerTask('dev', 'Builds for the DEV appengine environment.',
[ 'build', 'preprocess:dev', 'file-creator:dev' ]);
grunt.registerTask('staging', 'Builds for the STAGING appengine environment.',
[ 'build', 'preprocess:staging', 'file-creator:staging' ]);
grunt.registerTask('prod', 'Builds for the PROD appengine environment.',
[ 'build', 'preprocess:prod', 'file-creator:prod' ]);
};