-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
157 lines (151 loc) · 4.55 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* js-data-angular-mocks
* http://github.com/js-data/js-data-angular-mocks
*
* Copyright (c) 2014 Jason Dobry <http://js-data.github.io/js-data-angular-mocks>
* Licensed under the MIT license. <https://github.com/js-data/js-data-angular-mocks/blob/master/LICENSE>
*/
module.exports = function (grunt) {
'use strict';
require('jit-grunt')(grunt);
require('time-grunt')(grunt);
var webpack = require('webpack');
var pkg = grunt.file.readJSON('package.json');
var banner = 'js-data-angular-mocks\n' +
'@version ' + pkg.version + ' - Homepage <https://github.com/js-data/js-data-angular-mocks>\n' +
'@author Jason Dobry <[email protected]>\n' +
'@copyright (c) 2014-2015 Jason Dobry \n' +
'@license MIT <https://github.com/js-data/js-data-angular-mocks/blob/master/LICENSE>\n' +
'\n' +
'@overview A mock of js-data & js-data-angular for testing purposes.';
// Project configuration.
grunt.initConfig({
pkg: pkg,
clean: {
coverage: ['coverage/'],
dist: ['dist/']
},
watch: {
files: ['src/**/*.js'],
tasks: ['build']
},
uglify: {
dist: {
options: {
sourceMap: true,
sourceMapName: 'dist/js-data-angular-mocks.min.map',
banner: '/*!\n' +
'* js-data-angular-mocks\n' +
'* @version <%= pkg.version %> - Homepage <https://github.com/js-data/js-data-angular-mocks>\n' +
'* @author Jason Dobry <[email protected]>\n' +
'* @copyright (c) 2014-2015 Jason Dobry <https://github.com/js-data/>\n' +
'* @license MIT <https://github.com/js-data/js-data-angular-mocks/blob/master/LICENSE>\n' +
'*\n' +
'* @overview A mock of js-data & js-data-angular for testing purposes.\n' +
'*/\n'
},
files: {
'dist/js-data-angular-mocks.min.js': ['dist/js-data-angular-mocks.js']
}
}
},
karma: {
options: {
configFile: './karma.conf.js'
},
dev: {
browsers: ['Chrome'],
autoWatch: true,
singleRun: false
},
min: {
browsers: ['Chrome'],
autoWatch: false,
singleRun: true,
options: {
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/js-data/dist/js-data.js',
'bower_components/js-data-angular/dist/js-data-angular.js',
'dist/js-data-angular-mocks.min.js',
'karma.start.js',
'test/testApp.js',
'test/test.js'
]
}
},
ci: {
browsers: ['Firefox', 'PhantomJS']
}
},
coveralls: {
options: {
coverage_dir: 'coverage'
}
},
copy: {
dist: {
src: 'dist/js-data-angular-mocks.js',
dest: 'dist/js-data-angular-mocks.js',
options: {
process: function (content) {
return content.replace(/<%= pkg\.version %>/gi, pkg.version);
}
}
}
},
webpack: {
dist: {
entry: './src/index.js',
output: {
filename: './dist/js-data-angular-mocks.js',
libraryTarget: 'umd',
library: 'jsDataAngularMocksModuleName'
},
externals: {
'js-data': {
amd: 'js-data',
commonjs: 'js-data',
commonjs2: 'js-data',
root: 'JSData'
},
'js-data-angular': {
amd: 'js-data-angular',
commonjs: 'js-data-angular',
commonjs2: 'js-data-angular',
root: 'jsDataAngularModuleName'
},
'sinon': 'sinon',
'angular': 'angular'
},
module: {
loaders: [
{ test: /(src)(.+)\.js$/, exclude: /node_modules/, loader: 'babel-loader?blacklist=useStrict' }
],
preLoaders: [
{
test: /(src)(.+)\.js$|(test)(.+)\.js$/, // include .js files
exclude: /node_modules/, // exclude any and all files in the node_modules folder
loader: "jshint-loader?failOnHint=true"
}
]
},
plugins: [
new webpack.BannerPlugin(banner)
]
}
}
});
grunt.registerTask('test', ['build', 'karma:ci', 'karma:min']);
grunt.registerTask('build', [
'clean',
'webpack',
'copy',
'uglify:dist'
]);
grunt.registerTask('default', ['build']);
grunt.registerTask('go', ['build', 'watch']);
// Used by TravisCI
grunt.registerTask('ci', ['build', 'karma:ci']);
};