forked from briot/geneapro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
152 lines (140 loc) · 4.08 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
PRODUCTION=false;
MINIFIED_THIRD_PARTY=true;
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* Process LessCSS files to generate proper minified CSS
*/
less: {
options: {report: 'min', compress: PRODUCTION, cleancss: true},
build: {
files: {
'resources/tmp/lessoutput.css': [
'resources/css/*.less',
'resources/css/*.css']
}
}
},
/**
* Minify CSS files
*/
cssmin: {
options: {report: 'min'},
build: {
src: 'resources/tmp/lessoutput.css',
dest: 'resources/<%= pkg.name %>.min.css'
}
},
/**
* Compress the files
*/
/* compress: {
js: {
options: {mode: 'gzip', pretty: true},
files: [
{expand: true,
src: ['<%= pkg.name %>.min.js'],
cwd: 'resources/tmp',
ext: '.min.js_gz',
dest: 'resources/'}
]
},
css: {
options: {mode: 'gzip', pretty: true, level: 9},
files: [
{
src: 'resources/tmp/<%= pkg.name %>.min.css',
dest: 'resources/<%= pkg.name %>.css_gz'
}
]
}
},
*/
/**
* Automatically annotate angularJS source code, so that dependency
* injection is performed properly on controllers. Thus we can write
* our javascript as:
* crmApp.controller('foo', function($scope) {})
* and get automatically:
* crmApp.controller('foo', ['$scope', function($scope) {} ])
*/
ngAnnotate: {
options: {},
build: {
files: [{
expand: true,
cwd: 'resources',
src: ['js/*.js'],
dest: 'resources/tmp/',
ext: '.tmp.js'
}]
}
},
/**
* Add third-party libraries to our minified js, before we can compress.
*/
concat: {
options: { stripBanners: true },
build: {
src: [(MINIFIED_THIRD_PARTY ?
'node_modules/angular/angular.min.js' :
'node_modules/angular/angular.js'),
'node_modules/angular-ui-router/release/angular-ui-router.min.js',
(MINIFIED_THIRD_PARTY ?
'node_modules/d3/d3.min.js' :
'node_modules/d3/d3.js'),
'node_modules/angular-local-storage/dist/angular-local-storage.min.js',
'node_modules/angular-upload/angular-upload.js',
'resources/tmp/<%= pkg.name %>.min.js'],
dest: 'resources/<%= pkg.name %>.min.js',
nonnull: true // Warn when file is missing
}
},
/**
* Minify javascript files to save space
*/
uglify: {
options: {
report: 'min',
compress: PRODUCTION,
mangle: PRODUCTION,
beautify: !PRODUCTION,
drop_console: false // remove console.log calls
},
build: {
files: {
'resources/tmp/<%= pkg.name %>.min.js': [
'resources/tmp/js/app.tmp.js', // must be first
'resources/tmp/js/*.tmp.js']
},
notnull: true
}
},
watch: {
options: {
atBegin: true
},
css: {
files: ['Gruntfile.js', 'resources/css/*'],
tasks: ['allcss']
},
js: {
files: ['Gruntfile.js', 'resources/js/**/*.js'],
tasks: ['alljs']
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-ng-annotate');
grunt.loadNpmTasks('grunt-angular-templates');
grunt.registerTask('allcss', ['less', 'cssmin', /* 'compress:css' */]);
grunt.registerTask('alljs',
['ngAnnotate', 'uglify', 'concat', /* 'compress:js' */]);
grunt.registerTask('default', ['allcss', 'alljs']);
};