forked from CommitAnalyzingService/CAS_Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
184 lines (154 loc) · 4.29 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* Gruntfile
*
* If you created your Sails app with `sails new foo --linker`,
* the following files will be automatically injected (in order)
* into the EJS and HTML files in your `views` and `assets` folders.
*
* At the top part of this file, you'll find a few of the most commonly
* configured options, but Sails' integration with Grunt is also fully
* customizable. If you'd like to work with your assets differently
* you can change this file to do anything you like!
*
* More information on using Grunt to work with static assets:
* http://gruntjs.com/configuring-tasks
*/
module.exports = function (grunt) {
jsModuleNames = ['cg', 'angles', 'socket.io', 'sails'];
jsModules = {};
jsModuleNames.forEach(function (path) {
jsModules[path] = {
src: ['assets/js/modules/' + path + '/**/*.js'],
dest: '.tmp/public/js/modules/' + path + '.js'
};
});
// Get path to core grunt dependencies from Sails
var depsPath = grunt.option('gdsrc') || 'node_modules/sails/node_modules';
grunt.loadTasks(depsPath + '/grunt-contrib-clean/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-copy/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-concat/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-watch/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-uglify/tasks');
grunt.loadTasks(depsPath + '/grunt-contrib-cssmin/tasks');
grunt.loadTasks('node_modules/grunt-contrib-less/tasks');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
dev: {
files: [
{
expand: true,
cwd: './assets/public',
src: ['**/*'],
dest: '.tmp/public'
},
{
expand: true,
cwd: './assets/vendor',
src: ['angular-ui-router/release/*'],
dest: '.tmp/public/js/vendor'
},
]
},
build: {
files: [
{
expand: true,
cwd: '.tmp/public',
src: ['**/*'],
dest: 'www'
}
]
}
},
clean: {
dev: ['.tmp/public/**'],
build: ['www']
},
less: {
dev: {
files: [
{
expand: true,
cwd: 'assets/styles/',
src: ['*.less'],
dest: '.tmp/public/styles/',
ext: '.css'
}
]
}
},
concat: jsModules,
uglify: {
dist: {
src: ['.tmp/public/concat/production.js'],
dest: '.tmp/public/min/production.js'
}
},
cssmin: {
dist: {
src: ['.tmp/public/concat/production.css'],
dest: '.tmp/public/min/production.css'
}
},
watch: {
api: {
// API files to watch:
files: ['api/**/*']
},
js: {
// Assets to watch:
files: ['assets/js/**/*'],
// When assets are changed:
tasks: ['concat']
},
styles: {
// Assets to watch:
files: ['assets/styles/**/*'],
// When assets are changed:
tasks: ['less:dev']
}
}
});
// When Sails is lifted:
grunt.registerTask('default', [
'compileAssets',
'watch'
]);
grunt.registerTask('compileAssets', [
'clean:dev',
'less:dev',
'copy:dev',
'concat'
]);
// Build the assets into a web accessible folder.
// (handy for phone gap apps, chrome extensions, etc.)
grunt.registerTask('build', [
'compileAssets',
'clean:build',
'copy:build'
]);
// When sails is lifted in production
grunt.registerTask('prod', [
'clean:dev',
'less:dev',
'copy:dev',
'concat',
'uglify',
'cssmin',
]);
// When API files are changed:
// grunt.event.on('watch', function(action, filepath) {
// grunt.log.writeln(filepath + ' has ' + action);
// // Send a request to a development-only endpoint on the server
// // which will reuptake the file that was changed.
// var baseurl = grunt.option('baseurl');
// var gruntSignalRoute = grunt.option('signalpath');
// var url = baseurl + gruntSignalRoute + '?action=' + action + '&filepath=' + filepath;
// require('http').get(url)
// .on('error', function(e) {
// console.error(filepath + ' has ' + action + ', but could not signal the Sails.js server: ' + e.message);
// });
// });
};