forked from katspaugh/wavesurfer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
134 lines (126 loc) · 3.71 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
/*global module:false*/
module.exports = function(grunt) {
var path = require('path');
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> <%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* @license <%= pkg.license %> */',
// Task configuration.
concat: {
options: {
stripBanners: true
},
dist: {
src: [
'src/wavesurfer.js',
'src/util.js',
'src/webaudio.js',
'src/mediaelement.js',
'src/drawer.js',
'src/drawer.*.js'
],
dest: 'dist/wavesurfer.min.js'
}
},
commonjs: {
modules: {
banner: '<%= banner %>',
cwd: 'dist',
src: ['*.min.js'],
dest: 'dist/wavesurfer.cjs.js'
}
},
amd: {
modules: {
banner: '<%= banner %>',
cwd: 'dist',
src: ['*.min.js'],
dest: 'dist/wavesurfer.amd.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
options: {
sourceMap: 'dist/wavesurfer.min.js.map',
sourceMapRoot: '/'
},
src: '<%= concat.dist.src %>',
dest: '<%= concat.dist.dest %>'
},
plugins: {
files: grunt.file.expandMapping(['plugin/*.js'], 'dist/', {
rename: function(destBase, destPath) {
var newPath = destBase + destPath.replace('.js', '.min.js');
return newPath;
},
})
}
},
jshint: {
options: {
curly: true,
eqeqeq: false,
eqnull: true,
quotmark: "single",
browser: true,
// Missing "use strict" statement.
strict: false,
globals: {
WaveSurfer: true
},
},
ignore_warning: {
options: {
'-W004': true,
// Expected an assignment or function call and instead saw an expression
'-W030': true,
// {a} used out of scope
'-W038': true,
// Use '!==' to compare with ''
'-W041': true,
'-W056': true,
// Missing '()' invoking a constructor.
'-W058': true,
'-W079': true,
// Use the function form of 'use strict'
'-W097': true,
},
src: ['<%= concat.dist.src %>', 'plugin/*.js']
},
},
});
// ==========================================================================
// TASKS
// ==========================================================================
grunt.registerMultiTask('commonjs', 'Wrap .js files for commonjs.', function () {
this.files.forEach(function(file) {
return file.src.map(function(filepath) {
var original = grunt.file.read(path.join(file.cwd, filepath));
return grunt.file.write(file.dest, file.banner + '\n' +
original + '\nmodule.exports = WaveSurfer;');
});
});
});
grunt.registerMultiTask('amd', 'Wrap .js files for AMD.', function () {
this.files.forEach(function(file) {
return file.src.map(function(filepath) {
var definePath = (filepath.replace(/\.\w+$/, '')),
original = grunt.file.read(path.join(file.cwd, filepath));
return grunt.file.write(file.dest, file.banner +
'\ndefine(function () {\n' + original + '\nreturn WaveSurfer;\n});');
});
});
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task.
grunt.registerTask('default', ['jshint', 'concat', 'commonjs', 'amd', 'uglify']);
};