forked from stephenliberty/excel-builder.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·99 lines (90 loc) · 2.89 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
var _ = require('underscore');
module.exports = function(grunt) {
var compileOptions = {
baseUrl: ".",
name: "buildtools/index",
optimize: "none",
paths: {
"underscore": "node_modules/underscore/underscore",
"JSZip": "jszip"
},
shim: {
"underscore": {
"exports": '_'
}
}
};
var files = grunt.file.expand({
cwd: './dist',
filter: function (src) {
if(src.indexOf('WorksheetExportWorker') != -1) {
return false;
}
return true;
}
}, '../Excel/**/*.js');
files = files.map(function (filename) {
return filename.replace('.js', '');
})
files.push('../excel-builder');
grunt.file.write('./buildtools/index.js', "define(" + JSON.stringify(files) + ", function () {})");
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
compile: {
options: _.defaults({
out: "dist/<%= pkg.name %>.compiled.js"
}, compileOptions)
},
dist: {
options: _.defaults({
wrap: {
startFile: [
'./buildtools/start.js',
'./node_modules/almond/almond.js'
],
endFile: [
'./buildtools/end.js'
]
},
out: "dist/<%= pkg.name %>.dist.js"
}, compileOptions)
}
},
copy: {
jzip: {
src: 'node_modules/jszip/dist/jszip.js',
dest: 'jszip.js'
}
},
uglify: {
options: {
compress: {
drop_console: true
}
},
optimize: {
files: {
'dist/<%= pkg.name %>.compiled.min.js': ['dist/<%= pkg.name %>.compiled.js'],
'dist/<%= pkg.name %>.dist.min.js': ['dist/<%= pkg.name %>.dist.js']
}
}
},
jshint: {
options: {
jshintrc: true
},
all: {
//http://stackoverflow.com/questions/20695823/grunt-contrib-jshint-ignores-has-no-effect (hence the ! in front of **/*Worker.js
src: ['Excel/**/*.js', '!**/*Worker.js']
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['copy', 'jshint:all', 'requirejs', 'uglify']);
};