This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
141 lines (134 loc) · 3.97 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
/*
* js-data-asyncstorage
* https://github.com/js-data/js-data-asyncstorage
*
* Copyright (c) 2014-2015 Lukas Reichart <http://www.js-data.io/docs/dsasyncstorageadapter>
* Licensed under the MIT license. <https://github.com/js-data/js-data-asyncstorage/blob/master/LICENSE>
*/
module.exports = function (grunt) {
'use strict';
require('jit-grunt')(grunt, {
coveralls: 'grunt-karma-coveralls'
});
require('time-grunt')(grunt);
var webpack = require('webpack');
var pkg = grunt.file.readJSON('package.json');
var banner = 'js-data-asyncstorage\n' +
'@version ' + pkg.version + ' - Homepage <http://www.js-data.io/docs/dsasyncstorageadapter>\n' +
'@author Lukas Reichart <[email protected]>\n' +
'@copyright (c) 2015 Lukas Reichart \n' +
'@license MIT <https://github.com/lukasreichart/js-data-asyncstorage/blob/master/LICENSE>\n' +
'\n' +
'@overview js-data Adapter for react-native AsyncStorage.';
// Project configuration.
grunt.initConfig({
pkg: pkg,
clean: {
coverage: ['coverage/'],
dist: ['dist/']
},
watch: {
dist: {
files: ['src/**/*.js'],
tasks: ['build']
}
},
uglify: {
main: {
options: {
sourceMap: true,
sourceMapName: 'dist/js-data-asyncstorage.min.map',
banner: '/*!\n' +
'* js-data-asyncstorage\n' +
'* @version <%= pkg.version %> - Homepage <http://www.js-data.io/docs/dsasyncstorageadapter>\n' +
'* @author Lukas Reichart <[email protected]>\n' +
'* @copyright (c) 2015 Lukas Reichart\n' +
'* @license MIT <https://github.com/lukasreichart/js-data-asyncstorage/blob/master/LICENSE>\n' +
'*\n' +
'* @overview js-data Adapter for react-native AsyncStorage.\n' +
'*/\n'
},
files: {
'dist/js-data-asyncstorage.min.js': ['dist/js-data-asyncstorage.js']
}
}
},
webpack: {
dist: {
entry: './src/index.js',
output: {
filename: './dist/js-data-asyncstorage.js',
libraryTarget: 'umd',
library: 'DSAsyncStorageAdapter'
},
externals: {
'js-data': {
amd: 'js-data',
commonjs: 'js-data',
commonjs2: 'js-data',
root: 'JSData'
}
},
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)
]
}
},
karma: {
options: {
configFile: './karma.conf.js'
},
dev: {
browsers: ['Chrome'],
autoWatch: true,
singleRun: false,
reporters: ['spec'],
preprocessors: {}
},
min: {
browsers: ['Firefox', 'PhantomJS'],
options: {
files: [
'bower_components/js-data/dist/js-data.min.js',
'dist/js-data-asyncstorage.min.js',
'karma.start.js',
'test/**/*.js'
]
}
},
ci: {
browsers: ['Firefox', 'PhantomJS']
}
},
coveralls: {
options: {
coverage_dir: 'coverage'
}
}
});
grunt.registerTask('version', function (filePath) {
var file = grunt.file.read(filePath);
file = file.replace(/<%= pkg\.version %>/gi, pkg.version);
grunt.file.write(filePath, file);
});
grunt.registerTask('test', ['build', 'karma:ci', 'karma:min']);
grunt.registerTask('build', [
'clean',
'webpack',
'uglify:main'
]);
grunt.registerTask('go', ['build', 'watch:dist']);
grunt.registerTask('default', ['build']);
};