forked from bramstein/fontfaceobserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
101 lines (93 loc) · 2.79 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
module.exports = function (grunt) {
require('google-closure-compiler').grunt(grunt, {
max_parallel_compilations: require('os').cpus().length
});
var compilerOptions = {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
warning_level: 'VERBOSE',
summary_detail_level: 3,
language_in: 'ECMASCRIPT5_STRICT',
output_wrapper: '(function(){%output%}());',
use_types_for_optimization: true,
externs: ['externs-commonjs.js']
};
var src = [
'vendor/google/base.js',
'node_modules/closure-dom/src/dom.js',
'src/descriptors.js',
'src/ruler.js',
'src/observer.js',
'exports.js'
];
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
options: {
force: true
},
build: ['build']
},
exec: {
test: './node_modules/.bin/mocha-headless-chrome -f test/index.html',
deps: 'calcdeps -i src -i exports.js -p src -p ./vendor/google/base.js -p node_modules/closure-dom/src/dom.js -o deps > test/deps.js'
},
jshint: {
all: ['src/**/*.js'],
options: {
// ... better written as dot notation
'-W069': true,
// type definitions
'-W030': true,
// Don't make functions within loops
'-W083': true,
// Wrap the /regexp/ literal in parens to disambiguate the slash operator
'-W092': true
}
},
'closure-compiler': {
dist: {
files: {
'fontfaceobserver.js': src
},
options: compilerOptions
},
compile: {
files: {
'build/fontfaceobserver.js': src
},
options: compilerOptions
},
debug: {
files: {
'build/fontfaceobserver.debug.js': src
},
options: Object.assign({}, compilerOptions, {
debug: true,
formatting: ['PRETTY_PRINT', 'PRINT_INPUT_DELIMITER']
})
}
},
concat: {
options: {
banner: '/* Font Face Observer v<%= pkg.version %> - © Bram Stein. License: BSD-3-Clause */'
},
dist_promises: {
src: ['node_modules/promis/promise.js', 'build/fontfaceobserver.js'],
dest: 'fontfaceobserver.js'
},
dist: {
src: ['build/fontfaceobserver.js'],
dest: 'fontfaceobserver.standalone.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('compile', ['closure-compiler:compile']);
grunt.registerTask('debug', ['closure-compiler:debug']);
grunt.registerTask('default', ['compile']);
grunt.registerTask('test', ['jshint', 'exec:test']);
grunt.registerTask('dist', ['clean', 'closure-compiler:compile', 'concat:dist', 'concat:dist_promises']);
};