/
closure.config.js
executable file
·73 lines (56 loc) · 1.79 KB
/
closure.config.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
'use strict';
/**
* @fileoverview
*
* The configuration used for Google Closure Compiler.
*/
var path = require('path'),
bowerPath = __dirname + '/bower_components';
/**
* Factory method for generating a closure config object.
*
* Options passed to the Closure compiler.
* For more details, see:
* https://www.npmjs.org/package/gulp-closure-compiler
*
* Common pitfalls:
* https://developers.google.com/closure/compiler/docs/api-tutorial3#dangers
*
* @param {Object} options
* @return {Object}
*/
exports.createConfig = function(options)
{
var fileName = options.fileName;
return {
jar: path.resolve(
bowerPath + '/closure-compiler/lib/vendor/compiler.jar'
),
compilation_level: 'ADVANCED_OPTIMIZATIONS',
language_in: 'ECMASCRIPT5_STRICT',
manage_closure_dependencies: true,
// Inject dependencies automatically
angular_pass: true,
// Keep @export annotated code.
// Otherwise compiler may incorrectly flag code as being unused.
generate_exports: true,
// Ensure library properties and methods are not renamed
// on compilation, e.g.:
// angular.d -> angular.module
externs: [
path.resolve(
bowerPath +
'/closure-library-externs/contrib/externs/angular-1.2.js'
),
'externs/translator.js'
],
js_output_file: 'dist/' + fileName,
// Wrap compiled code in IIFE to protect global namespace,
// and add URL to sourcemap.
output_wrapper: '(function(){%output%})();' +
'//# sourceMappingURL=' + fileName + '.map',
// Generate source maps
create_source_map: 'dist/' + fileName + '.map',
source_map_format: 'V3'
};
};