-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
109 lines (88 loc) · 3.02 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
module.exports = function (grunt) {
grunt.initConfig({
less: {
dist: {
src: ['./web/assets/less/*'],
dest: './web/assets/dist/css/styles.css'
},
test: {
src: ['./web/assets/less/file1.less'],
dest: './web/assets/dist/css/file1.css'
}
},
cssmin: {
dist: {
src: ['./web/assets/dist/css/styles.css'],
dest: './web/assets/dist/css/styles.min.css'
}
},
concat: {
dist: {
src: ['./web/assets/js/app/*/*/module.js', './web/assets/js/app/**/*.js'],
dest: './web/assets/dist/js/built.js'
}
},
ngAnnotate: {
dist: {
src: ['./web/assets/dist/js/built.js'],
dest: './web/assets/dist/js/built.js'
}
},
uglify: {
dist: {
src: ['./web/assets/dist/js/built.js'],
dest: './web/assets/dist/js/built.min.js'
}
},
shell: {
removeSymfonyCache: {
command: 'rm -rf ./app/cache'
}
},
watch: {
files: ['./web/assets/**'],
tasks: ['default'],
}
});
grunt.registerTask('blueprint2json', 'Generate js version of apiary file.', function () {
var done = this.async();
var parser = require('protagonist');
var content = grunt.file.read('API.md');
parser.parse(content, function (error, result) {
if (error) {
console.log(error);
return;
}
var json = JSON.stringify(result.ast);
grunt.file.write('web/assets/blueprint/blueprint.json', json);
done();
});
});
/**
* loading Grunt plugins
*/
// plugin less preprocessor
grunt.loadNpmTasks('grunt-contrib-less');
// plugin for minify css files
grunt.loadNpmTasks('grunt-contrib-cssmin');
// plugin for concat files
grunt.loadNpmTasks('grunt-contrib-concat');
// plugin for annotate AngularJS files
grunt.loadNpmTasks('grunt-ng-annotate');
// plugin for minify js files
grunt.loadNpmTasks('grunt-contrib-uglify');
// plugin for using shell commands
grunt.loadNpmTasks('grunt-shell');
// plugin for watching for change and play tasks
grunt.loadNpmTasks('grunt-contrib-watch');
/**
* Declaration of grouped tasks
* the default task (when just tiping 'grunt') will load tasks 'less:dist', 'cssmin', 'concat' and 'uglify'
* 'grunt watch-src' will load task 'default' then 'watch' (the declaration order is important)
*
* task 'watch-src' will not stop, but grunt will stay active
* to see any possible change
*/
grunt.registerTask('default', ['less:dist', 'cssmin', 'concat', 'ngAnnotate', 'uglify', 'shell:removeSymfonyCache']);
grunt.registerTask('watch-src', ['default', 'watch']);
};