forked from jasonewall/angularjs-rails-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
110 lines (96 loc) · 2.63 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
module.exports = function(grunt) {
var path = require('path');
var srcFolder = 'vendor/assets/javascripts/angularjs/rails/resource/',
srcFiles = ["index.js", "utils/**/*.js", "serialization.js", "resource.js"].map(function(glob) {
return srcFolder + glob;
}),
extensionFiles = ["extensions/**/*.js"].map(function(glob) {
return srcFolder + glob;
});
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/**\n' +
' * <%= pkg.description %>\n' +
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @link <%= pkg.homepage %>\n' +
' * @author <%= pkg.author %>\n' +
' */\n'
},
dirs: {
dest: 'dist'
},
clean: ['<%= dirs.dest %>'],
copy: {
extensions: {
files: [
{expand: true, flatten: true, src: extensionFiles, dest: '<%= dirs.dest %>/extensions'}
]
}
},
concat: {
options: {
banner: "<%= meta.banner %>"
},
dist: {
src: srcFiles,
dest: '<%= dirs.dest %>/<%= pkg.name %>.js',
options: {
process: function(src, filepath) {
return src.replace(/^\/\/= require.*\n/gm, '');
}
}
}
},
compress: {
dist: {
options: {
archive: '<%= dirs.dest %>/angularjs-rails-resource.zip'
},
files: [
{expand: true, cwd: '<%= dirs.dest %>', src: ['**/*.js']}
]
}
},
uglify: {
options: {
banner: "<%= meta.banner %>"
},
dist: {
files: [
{expand: true, cwd: '<%= dirs.dest %>', src: ['**/*.js'], dest: '<%= dirs.dest %>', ext: '.min.js'}
]
}
},
jshint: {
files: ['gruntfile.js'].concat(srcFiles),
options: {
// options here to override JSHint defaults
globals: {
angular: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
},
bump: {
options: {
files: ['package.json', 'bower.json'],
commit: false,
createTag: false,
push: false
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-bump');
grunt.registerTask('default', ['jshint', 'clean', 'concat', 'copy', 'uglify', 'compress']);
};