forked from publiclab/Leaflet.DistortableImage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
124 lines (110 loc) · 2.9 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
const webpackConfig = require('./webpack.config.js');
module.exports = function(grunt) {
// load npm tasks for grunt-* libs, excluding grunt-cli
require('matchdep').filterDev('{grunt,gruntify}-*').filter(function(pkg) {
return ['grunt-cli'].indexOf(pkg) < 0;
}).forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
webpack: {
myConfig: webpackConfig,
},
eslint: {
src: ['src/**/*.js', 'test/**/*.js'],
},
karma: {
development: {
configFile: 'test/karma.conf.js',
},
test: {
configFile: 'test/karma.conf.js',
},
},
// Minify SVGs from svg directory, output to svg-min
svgmin: {
dist: {
files: [
{
expand: true,
cwd: 'assets/icons/svg',
src: ['*.svg'],
dest: 'assets/icons/svg-min/',
ext: '.svg',
},
],
},
options: {
plugins: [
{ removeViewBox: false },
{ removeEmptyAttrs: false },
{ removeTitle: true }, // "leaflet-toolbar" lets us specify the title attribute later
{
removeAttrs: {
attrs: ['xmlns', 'fill'],
},
},
],
},
},
svg_sprite: {
options: {
// Task-specific options go here.
},
dist: {
expand: true,
cwd: 'assets/icons/svg-min/',
src: ['*.svg'],
dest: 'assets/icons/',
options: {
log: 'info',
mode: {
symbol: {
sprite: 'sprite.symbol.svg',
example: true,
},
},
},
},
},
watch: {
options: {
livereload: true,
},
source: {
files: ['src/**/*.js', 'test/**/*.js', 'Gruntfile.js'],
tasks: ['eslint', 'karma:development:start'],
},
},
});
/* Run tests once. */
grunt.registerTask('test', ['eslint', 'karma:test']);
grunt.registerTask('build', [
'eslint',
'karma:development:start',
'coverage',
'webpack',
]);
// recompile svg icon sprite
grunt.registerTask('icons', ['svgmin', 'svg_sprite']);
grunt.registerTask('coverage', 'CLI reporter for karma-coverage', function() {
var coverageReports = grunt.file.expand('coverage/*/coverage.txt');
var reports = {};
var report; var i; var len;
for (i = 0, len = coverageReports.length; i < len; i++) {
report = grunt.file.read(coverageReports[i]);
if (!reports[report]) {
reports[report] = [coverageReports[i]];
} else {
reports[report].push(coverageReports[i]);
}
}
for (report in reports) {
if (reports.hasOwnProperty(report)) {
for (i = 0, len = reports[report].length; i < len; i++) {
grunt.log.writeln(reports[report][i]);
}
grunt.log.writeln(report);
}
}
});
};