-
Notifications
You must be signed in to change notification settings - Fork 270
/
Gruntfile.js
127 lines (120 loc) · 3.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
module.exports = function(grunt) {
grunt.initConfig({
ngmin: {
directives: {
src: ['src/*.js'],
dest: 'build/directives.js'
}
},
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: ['build/*.js'],
dest: 'dist/angular-charts.js'
}
},
uglify : {
dist: {
src: 'dist/angular-charts.js',
dest: 'dist/angular-charts.min.js'
}
},
clean : ["build"],
watch: {
scripts: {
files: ['src/**/*.js', 'src/**/*.html', 'src/**/*.css'],
tasks: ['ngmin', 'htmlmin', 'html2js', 'csso', 'css2js', 'concat', 'uglify', 'clean'],
options: {
debounceDelay: 250,
},
}
},
htmlmin: {
main: {
options: {
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeComments: true
},
files: {
'build/right.min.html': 'src/templates/right.html',
'build/left.min.html': 'src/templates/left.html',
}
}
},
html2js: {
options: {
base : 'build',
module : 'angularChartsTemplates',
rename : function(name) {
return 'angularChartsTemplate_' + name.replace('.min.html', '');
}
},
main: {
src: ['build/*.min.html'],
dest: 'build/templates.js'
},
},
// CSS -> minfied CSS -> JS.
csso: {
main: {
files: {
'build/styles.min.css': ['src/styles.css']
}
}
},
css2js: {
main: {
src: 'build/styles.min.css',
dest: 'build/styles.js'
}
},
karma: {
unit: {
configFile: 'karma.conf.js'
}
},
prompt: {
release: {
options: {
questions: [
{
config: 'release', // arbitray name or config for any other grunt task
type: 'confirm', // list, checkbox, confirm, input, password
message: 'Are you sure?', // Question to ask the user, function needs to return a string,
default: false // default value if nothing is entered
}
]
}
},
},
copy: {
bowerPreRelease: {
files: [
{ src: 'dist/angular-charts.js', dest: 'dist/angular-charts.tmp.js' },
{ src: 'dist/angular-charts.min.js', dest: 'dist/angular-charts.min.tmp.js' }
]
}
},
shell: {
bowerRelease: {
command: [
'git checkout bower',
'git checkout master -- bower.json',
'mv -f dist/angular-charts.tmp.js dist/angular-charts.js',
'mv -f dist/angular-charts.min.tmp.js dist/angular-charts.min.js',
"git commit -am 'release <%= pkg.version %>'",
'git tag <%= pkg.version %>'
].join('&&')
}
}
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['ngmin', 'htmlmin', 'html2js', 'csso', 'css2js', 'concat', 'uglify', 'clean', 'karma']);
grunt.registerTask('release', ['karma', 'prompt', 'bowerValidateRelease']);
grunt.registerTask('bowerValidateRelease', 'Make sure that we really want to release!', function() {
if(grunt.config('release') === true) {
grunt.task.run('default', 'copy:bowerPreRelease', 'shell:bowerRelease');
}
});
};