-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
136 lines (122 loc) · 3.87 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
'use strict';
module.exports = function(grunt) {
// ===========================================================================
// CONFIGURE GRUNT ===========================================================
// ===========================================================================
grunt.initConfig({
// get the configuration info from package.json ----------------------------
// this way we can use things like name and version (pkg.name)
pkg: grunt.file.readJSON('package.json'),
// configure jshint to validate js files -----------------------------------
jshint: {
options: {
reporter: require('jshint-stylish'),
jshintrc: true
},
all: ['grunfile.js', 'client/js/**/*.js']
},
// configure uglify to minify js files -------------------------------------
uglify: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n',
mangle: false
},
build: {
files: {
'public/js/main.min.js': 'client/**/*.js'
}
}
},
// compile less stylesheets to css -----------------------------------------
less: {
build: {
files: {
'public/css/main.css': 'client/less/main.less'
}
}
},
// configure cssmin to minify css files ------------------------------------
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},
build: {
files: {
'public/css/main.min.css': 'public/css/main.css'
}
}
},
// configure watch to auto update ------------------------------------------
watch: {
stylesheets: {
files: ['client/less/**/*.less'],
tasks: ['less', 'cssmin']
},
scripts: {
files: 'client/js/**/*.js',
tasks: ['jshint', 'uglify']
}
},
// Run Mongo DB !!
shell: {
mongo: {
command: 'mongod --dbpath ./data',
options: {
async: true,
stdout: false,
stderr: true
}
}
},
// Run Node Server
nodemon: {
prod: {
script: 'server.js',
options: {
watch: 'nothing.js'
}
},
dev: {
script: 'server.js'
}
},
concurrent: {
default: {
tasks: ['shell:mongo','nodemon:dev', 'watch'],
options: {
logConcurrentOutput: true
}
},
prod: {
tasks: ['shell:mongo','nodemon:prod'],
options: {
logConcurrentOutput: true
}
},
openshift: {
tasks: ['nodemon:prod'],
options: {
logConcurrentOutput: true
}
}
}
});
// ===========================================================================
// LOAD GRUNT PLUGINS ========================================================
// ===========================================================================
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
// ===========================================================================
// CREATE TASKS ==============================================================
// ===========================================================================
grunt.registerTask('prepare', ['jshint', 'uglify', 'less', 'cssmin']);
grunt.registerTask('default', ['prepare', 'concurrent:default']);
grunt.registerTask('prod', ['prepare', 'concurrent:prod']);
grunt.registerTask('openshift', ['prepare', 'concurrent:openshift']);
};