-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
136 lines (134 loc) · 4.78 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
127
128
129
130
131
132
133
134
135
136
/*global module:false*/
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/* <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>* Copyright (c) <%= pkg.author.name %>; Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n'
},
concat: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
src: ['dist/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
requirejs: {
'gsloader.js': {
options: {
baseUrl: 'src',
out: 'dist/gsloader.js',
include: ['gsloader'],
paths: {
'jquery': 'empty:',
'logger': 'empty:',
'google-api-client': 'empty:',
'gsloader': 'js/gsloader'
},
optimize: 'none'
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
}
}
},
jsbeautifier: {
files: '<%= jshint.files %>',
options: {
'js': {
'preserve_newlines': true,
'max_preserve_newlines': 2
}
}
},
connect: {
jasmine: {
options: {
port: 8889
}
}
},
open: {
jasmine: {
url: '<%= jasmine.all.options.host %>_SpecRunner.html'
}
},
jasmine: {
all: {
options: {
specs: ['jasmine/specs/**/*spec.js'],
host: 'http://127.0.0.1:<%= connect.jasmine.options.port %>/',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: 'src/require-config.js',
requireConfig: {
baseUrl: 'src',
paths: {
'jquery-fixture': '../jasmine/lib/jquery-fixture/jquerymx-3.2.custom',
'google-api-client': '../jasmine/lib/google-api-client',
'jasmine-injector': 'lib/jasmine-injector/jasmine-injector',
'requirejs-injector': 'lib/jasmine-injector/requirejs-resolver'
},
shim: {
'jquery-fixture': 'jquery'
},
deps: ['jquery', 'jquery-fixture', 'requirejs-injector']
}
}
}
}
},
jshint: {
files: ['package.json', 'Gruntfile.js', 'src/**/*.js', '!src/lib/**/*', 'jasmine/specs/**/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
shell: {
npm: {
command: 'npm install',
options: {
failOnError: true,
stdout: true,
stderr: true
}
}
},
bower: {
install: {
options: {
targetDir: 'src/lib',
layout: 'byComponent',
verbose: true,
cleanTargetDir: true,
cleanBowerDir: true
}
}
}
});
/* These plugins provide necessary tasks. */
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-jsbeautifier');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-bower-task');
/* Register tasks. */
grunt.registerTask('default', ['shell:npm', 'jsbeautifier', 'jshint', 'dist', 'connect', 'jasmine']);
grunt.registerTask('dist', ['bower:install', 'requirejs', 'concat', 'uglify']);
grunt.registerTask('test', ['dist', 'connect', 'jasmine']);
grunt.registerTask('jasmine-server', ['dist', 'jasmine:all:build', 'open:jasmine', 'connect::keepalive']);
};