forked from frapontillo/angular-bootstrap-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
129 lines (122 loc) · 3.21 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
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
src: 'src',
dist: 'dist',
test: 'test',
temp: '.temp'
};
try {
yeomanConfig.src = require('./bower.json').appPath || yeomanConfig.src;
} catch (e) {}
grunt.initConfig({
yeoman: yeomanConfig,
pkg: grunt.file.readJSON('bower.json'),
meta: {
banner:
'/**\n' +
' * <%= pkg.name %>\n' +
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @author <%= pkg.author.name %> (<%= pkg.author.email %>)\n' +
' * @link <%= pkg.homepage %>\n' +
' * @license <%= _.map(pkg.licenses, function(l) { return l.type + "(" + l.url + ")"; }).join(", ") %>\n' +
'**/\n\n'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= yeoman.src %>/**/*.js'
],
test: {
src: ['<%= yeoman.test %>/spec/**/*.js'],
options: {
jshintrc: '<%= yeoman.test %>/.jshintrc'
}
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
unit: {
options: {
singleRun: false
}
},
final: {
options: {
singleRun: true
}
},
travis: {
browsers: ['PhantomJS'],
options: {
singleRun: true
}
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
},
temp: {
src: ['<%= yeoman.dist %>/<%= yeoman.temp %>']
}
},
ngmin: {
dist: {
expand: true,
cwd: '<%= yeoman.src %>',
src: ['**/*.js'],
dest: '<%= yeoman.dist %>/<%= yeoman.temp %>'
}
},
concat: {
options: {
banner: '<%= meta.banner %>\'use strict\';\n',
process: function(src, filepath) {
return '// Source: ' + filepath + '\n' +
src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
},
dist: {
src: ['common/*.js', '<%= yeoman.dist %>/<%= yeoman.temp %>/**/*.js'],
dest: '<%= yeoman.dist %>/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
min: {
files: {
'<%= yeoman.dist %>/<%= pkg.name %>.min.js': '<%= concat.dist.dest %>'
}
}
}
});
// Test the directive
grunt.registerTask('test', ['jshint', 'karma:unit']);
grunt.registerTask('test-travis', ['jshint', 'karma:travis']);
// Build the directive
// - clean, cleans the output directory
// - ngmin, prepares the angular files
// - concat, concatenates and adds a banner to the debug file
// - uglify, minifies and adds a banner to the minified file
// - clean:temp, cleans the ngmin-ified directory
grunt.registerTask('build', ['clean', 'ngmin', 'concat', 'uglify', 'clean:temp']);
// Default task, do everything
grunt.registerTask('default', ['test-travis', 'build']);
};