forked from ilkkamtk/sound-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·100 lines (96 loc) · 3.6 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
module.exports = function (grunt) {
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Concatenate all vendor scripts to vendor.js and app scripts to app.js
concat: {
options: {},
vendor: {
src: [
'bower_components/jquery/dist/jquery.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/angular/angular.min.js',
'bower_components/angular-ui-router/release/angular-ui-router.js',
'bower_components/ngCordova/dist/ng-cordova.js'
],
dest: 'build/vendor.js'
},
app: {
src: ['src/**/*.js'],
dest: 'build/app.js'
}
},
// Minify and add a banner comment to app js file:
uglify: {
options: {
mangle: false, // Breaks angular if true (default)
banner: '/** <%= pkg.name %> v<%= pkg.version %> build <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: '<%= concat.app.dest %>',
dest: 'build/app.min.js'
}
},
// Check all js files with jshint:
jshint: {
files: ['Gruntfile.js', 'src/**/*.js'],
options: {
// options to override JSHint defaults
globals: {
angular: true,
module: true,
document: true
}
}
},
// Copy specified files to build folder:
copy: {
css: {
files: [{
expand: true,
flatten: true,
src: ['bower_components/bootstrap/dist/css/bootstrap.min.css',
'src/**/*.css'],
dest: 'build/css/'
}]
},
views: {
files: [{
expand: true,
flatten: true,
src: ['src/views/*.html'],
dest: 'build/views/'
}]
},
html: {
files: [{
expand: true,
flatten: true,
src: ['src/*.html'],
dest: 'build/'
}],
options: {
process: function (content, srcpath) {
// Remove all html comments
content = content.replace(/<!--[\s\S]*?-->\s*\n*/g, "");
// Change bootstrap css file path
content = content.replace(/..\/bower_components\/bootstrap\/dist\//g, "");
// Remove all script elements
content = content.replace(/<script.*script>\s*\n*/g, "");
// Add concatenated js files just before closing body tag
content = content.replace(/<\/body>/, '<script src="cordova.js"></script>\n' + '<script src="vendor.js"></script>\n' +
'<script src="app.min.js"></script>\n</body>');
return content;
}
}
}
}
});
// Load the plugins that provide the grunt tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
// Default tasks
grunt.registerTask('default', ['concat', 'jshint', 'uglify', 'copy']);
};