-
Notifications
You must be signed in to change notification settings - Fork 57
/
Gruntfile.js
135 lines (116 loc) · 3.85 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
module.exports = function(grunt) {
grunt.initConfig({
/**
* @property pkg
* @type {Object}
*/
pkg: grunt.file.readJSON('package.json'),
/**
* @property jshint
* @type {Object}
*/
jshint: {
all: 'components/*.js',
options: {
jshintrc: '.jshintrc'
}
},
/**
* @property uglify
* @type {Object}
*/
uglify: {
options: {
banner: '/*! <%= pkg.name %> by <%= pkg.author %> created on <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: ['dist/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
/**
* @property compress
* @type {Object}
*/
compress: {
main: {
options: {
archive: 'releases/<%= pkg.version %>.zip'
},
files: [
{ flatten: true, src: 'dist/<%= pkg.name %>.js', dest: './', filter: 'isFile' }
]
}
},
/**
* @property karma
* @type {Object}
*/
karma: {
unit: {
configFile: 'KarmaUnit.js',
background: false,
browsers: ['Firefox']
}
},
/**
* @property concat
* @type {Object}
*/
concat: {
options: {
separator: '\n\n'
},
dist: {
src: ['components/Service.js', 'components/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
/**
* @property copy
* @type {Object}
*/
copy: {
vendor: {
expand: true,
flatten: true,
src: ['components/*'],
dest: 'example/js/vendor/ng-video',
filter: 'isFile'
},
release: {
src: 'releases/<%= pkg.version %>.zip',
dest: 'releases/master.zip'
}
}
});
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('build', ['concat', 'uglify', 'copy', 'compress']);
grunt.registerTask('test', ['jshint', 'karma']);
grunt.registerTask('default', ['jshint', 'karma', 'concat', 'copy', 'uglify', 'compress']);
grunt.registerTask('custom', 'Compile a custom version of ngVideo.', function() {
var output = 'dist/custom/<%= pkg.name %>.custom.js',
modules = (grunt.option('modules') || '').split(/,/ig),
files = modules.map(function map(file) {
return 'components/' + file + '.js';
});
files.unshift('components/Bootstrap.js');
files.unshift('components/Screen.js');
files.unshift('components/Service.js');
// Create development version.
grunt.config.set('concat.options.separator', '\n\n');
grunt.config.set('concat.dist.src', files);
grunt.config.set('concat.dist.dest', output);
grunt.task.run('concat');
// Create minified version.
grunt.config.set('uglify.options.banner', '/*! <%= pkg.name %> Custom by <%= pkg.author %> created on <%= grunt.template.today("yyyy-mm-dd") %> */\n');
grunt.config.set('uglify.build.src', 'dist/custom/<%= pkg.name %>.custom.js');
grunt.config.set('uglify.build.dest', 'dist/custom/<%= pkg.name %>.custom.min.js');
grunt.task.run('uglify');
});
};