-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathGruntfile.js
126 lines (105 loc) · 2.69 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
'use strict';
module.exports = function(grunt) {
var path = require('path');
var versionify = require('browserify-versionify');
var browserifyConfig = {
options: {
browserifyOptions: {
standalone: 'Raven' // umd
},
transform: [versionify]
},
core: {
src: 'src/singleton.js',
dest: 'build/raven.js'
}
};
var gruntConfig = {
pkg: grunt.file.readJSON('package.json'),
clean: ['build'],
browserify: browserifyConfig,
uglify: {
options: {
sourceMap: true,
// Only preserve comments that start with (!)
preserveComments: /^!/,
// Minify object properties that begin with _ ("private"
// methods and values)
mangleProperties: {
regex: /^_/
},
compress: {
booleans: true,
conditionals: true,
dead_code: true,
join_vars: true,
pure_getters: true,
sequences: true,
unused: true,
global_defs: {
__DEV__: false
}
}
},
dist: {
src: ['build/**/*.js'],
ext: '.min.js',
expand: true
}
},
release: {
options: {
npm: false,
commitMessage: 'Release <%= version %>'
}
},
sri: {
build: {
src: ['build/**/*.js'],
options: {
dest: 'build/sri.json',
pretty: true
}
}
}
};
grunt.initConfig(gruntConfig);
// Custom Grunt tasks
grunt.registerTask('version', function() {
var pkg = grunt.config.get('pkg');
// Verify version string in source code matches what's in package.json
var Raven = require('./src/raven');
if (Raven.prototype.VERSION !== pkg.version) {
return grunt.util.error(
'Mismatched version in src/raven.js: ' +
Raven.prototype.VERSION +
' (should be ' +
pkg.version +
')'
);
}
if (grunt.option('dev')) {
pkg.release = 'dev';
} else {
pkg.release = pkg.version;
}
grunt.config.set('pkg', pkg);
});
// Grunt contrib tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
// 3rd party Grunt tasks
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-gitinfo');
grunt.loadNpmTasks('grunt-sri');
// Build tasks
grunt.registerTask('_prep', ['clean', 'gitinfo']);
grunt.registerTask(
'browserify.core',
['_prep', 'browserify:core']
);
grunt.registerTask('build.core', ['browserify.core', 'uglify']);
grunt.registerTask('build', ['build.core']);
};