This repository has been archived by the owner on Apr 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Gruntfile.js
127 lines (109 loc) · 3.12 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
var _ = require('lodash');
module.exports = function(grunt) {
grunt.initConfig ({
less: {
options: {
ieCompat: true
},
files: {
expand: true,
cwd: 'app/less/',
src: '*.less',
dest: 'app/css/',
ext: '.css'
}
},
colorguard: {
files: {
src: 'app/css/*.css'
}
},
connect: {
development: {
options: {
port: process.env.PORT || 8083,
base: './app',
livereload: 3572,
middleware: function(connect, options, middlewares) {
var morgan = require('morgan')
middlewares.unshift(morgan('dev'))
return middlewares;
}
}
},
heroku: {
options: {
port: process.env.PORT,
base: './app',
keepalive: true
}
}
},
watch: {
css: {
files: 'app/less/*.less',
tasks: ['less'],
options: {
livereload: 3572
}
},
templates: {
files: 'app/**/*.html',
options: {
livereload: 3572
}
},
config: {
files: 'config/modulusui*.conf.js',
tasks: 'config',
options: {
livereload: 3572
}
}
}
})
grunt.loadNpmTasks('grunt-contrib-less')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-colorguard')
grunt.registerTask('default', ['build'])
grunt.registerTask('serve', ['build', 'connect:development', 'watch'])
grunt.registerTask('heroku', ['connect:heroku'])
grunt.registerTask('build', ['config', 'less', 'colorguard'])
grunt.registerTask('config', function() {
var config = require('./config/modulusui.conf.js');
var env = {
conf: process.env.MODULUS_UI_CONF || process.env.bamboo_MODULUS_UI_CONF,
base: process.env.MODULUS_API_BASE_URL ||
process.env.bamboo_MODULUS_API_BASE_URL,
readOnly: process.env.MODULUS_API_READ_ONLY ||
process.env.bamboo_MODULUS_API_READ_ONLY
};
grunt.log.writeln("Including config from modulusui.conf.js");
if (grunt.file.exists('./config/modulusui-dev.conf.js')) {
grunt.log.writeln("Including config from modulusui-dev.conf.js");
var devConfig = require('./config/modulusui-dev.conf.js');
config = _.assign(config, devConfig);
}
if (env.conf) {
try {
var override = JSON.parse(env.conf);
grunt.log.writeln("Including config from environment in MODULUS_UI_CONF");
config = _.merge(config, override);
} catch (error) {
grunt.log.error("Failed to parse configuration in MODULUS_UI_CONF " +
"environment variable.");
}
}
if (env.base) {
config.api.baseUrl = env.base;
}
if (env.readOnly) {
config.api.readOnly = env.readOnly;
}
var contents = "angular.module('modulusOne.config', []).constant('Config', " +
JSON.stringify(config) + ");"
grunt.file.write('app/js/config.js', contents);
grunt.log.writeln("Wrote current configuration to app/js/config.js");
})
}