This repository was archived by the owner on Oct 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathGruntfile.js
116 lines (105 loc) · 2.99 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
module.exports = function(grunt) {
// project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
ngDefine: {
options: {
name : 'ngDefine',
baseUrl: './src',
paths: {
'angular': 'empty:'
},
out: 'build/ngDefine.min.js'
}
},
ngr: {
options: {
optimize: 'none',
name : 'ngr',
baseUrl: './src',
out: 'build/ngr.js'
}
},
bower: {
options: {
name : 'ngDefine',
optimize: 'none',
baseUrl: './src',
paths: {
'angular': 'empty:'
},
out: 'dist/ngDefine.js'
}
}
},
ngr: {
/**
* Test configuration for ngr that optimizes
* the module test/unit/testapp
*/
testMinify: {
options: {
name : 'testapp/app',
out: 'build/testapp/app.min.js',
paths: {
'ngDefine' : 'build/ngDefine.min',
'jquery' : 'lib/jquery/jquery-2.0.0',
'angular' : 'lib/angular/angular',
'angular-resource' : 'lib/angular/angular-resource'
},
optimize: 'uglify2',
shim: {
'angular' : { deps: [ 'jquery' ], exports: 'angular' },
'angular-resource': { deps: [ 'angular' ] },
'angular-mocks': { deps: [ 'angular' ] }
},
packages: [
{ name: 'testapp', location: 'test/unit/testapp' },
{ name: 'my-module', location: 'test/unit/testapp/my-module' },
{ name: 'my-other-module', location: 'test/unit/testapp/my-other-module' }
]
}
}
},
karma: {
unit: {
configFile: 'config/karma.unit.js',
},
single: {
configFile: 'config/karma.unit.js',
singleRun: true,
browsers: [ 'PhantomJS' ]
},
singleOptimized: {
configFile: 'config/karma.unit.optimized.js',
singleRun: true,
browsers: [ 'PhantomJS' ]
},
singleNgr: {
configFile: 'config/karma.unit.ngr.js',
singleRun: true,
browsers: [ 'PhantomJS' ]
}
}
});
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-requirejs');
// default task: minify sources and publish to ./build
grunt.registerTask( 'default', [ 'test' ]);
// travis task
grunt.registerTask('travis', [ 'default' ]);
// sample task for ngDefine optimization
grunt.registerMultiTask('ngr', 'Minify ngDefine powered application', function() {
var done = this.async();
var ngr = require('./build/ngr.js');
ngr.optimize(this.data.options, function() {
done('success');
}, function(e) {
console.log('Error during minify: ', e);
done(new Error('With failures: ' + e));
});
});
// test task
grunt.registerTask( 'test', [ 'requirejs', 'ngr', 'karma:single', 'karma:singleOptimized', 'karma:singleNgr' ]);
};