-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGruntfile.js
More file actions
147 lines (139 loc) · 5.16 KB
/
Gruntfile.js
File metadata and controls
147 lines (139 loc) · 5.16 KB
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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
lib_name: 'jnottery-v<%= pkg.version %>',
full_name: 'jnottery-full-v<%= pkg.version %>',
nano_name: 'nano',
base64_name: 'base64',
rangy_dir: grunt.option('rangy'),
view_build_dir: 'build/views',
lib_banner: '\
\
// <%= pkg.name %> library \n\
// Copyright (c) 2014, <%= pkg.author %> <tomasz@zdunczyk.org> \n\
// Released under the <%= pkg.license %> license. \n\
\
\n',
full_banner: '\
\
// <%= pkg.name %> Full Release \n\
// Parts of this code are written, and maintained by diffrent authors, see copyright notes below. \n\
// Copyright (c) 2014, <%= pkg.author %> <tomasz@zdunczyk.org> \n\
// @see <%= pkg.homepage %> \n\
// The library itself and all of its dependencies are released under the <%= pkg.license %> license. \n\
// Requires jQuery, other dependencies included. \n\
\
\n',
tooltip: {
views: 'src/tooltip/view/*.html',
output: '<%= view_build_dir %>'
},
concat: {
mindist: {
options: {
separator: '\n\n',
banner: '<%= full_banner %>'
},
src: [
'libs/0xJQ/release/xJQ.min.js',
'libs/rangy/rangy-core.js',
'libs/rangy/rangy-cssclassapplier.js',
'libs/rayson/release/rayson.min.js',
'build/<%= base64_name %>.min.js',
'build/<%= nano_name %>.min.js',
'build/<%= lib_name %>.min.js'
],
dest: 'build/<%= full_name %>.min.js'
},
dist: {
options: {
separator: '\n\n',
banner: '<%= full_banner %>'
},
src: [
'libs/0xJQ/release/xJQ.js',
'<%= rangy_dir %>/rangy-core.js',
'<%= rangy_dir %>/rangy-cssclassapplier.js',
'libs/rayson/release/rayson.js',
'libs/js-base64/<%= base64_name %>.js',
'libs/nano/<%= nano_name %>.js',
'build/<%= lib_name %>.js'
],
dest: 'build/<%= full_name %>.js'
},
lib: {
options: {
separator: ';',
banner: '<%= lib_banner %>(function() { \n',
footer: '\n })();'
},
src: [
'<%= view_build_dir %>/main.js',
'src/tt.js',
'src/core.js',
'src/tooltip.js',
'src/range.js',
'src/vendor.js',
'src/core/*.js',
'src/tooltip/*.js',
'src/vendor/*.js'
],
dest: 'build/<%= lib_name %>.js'
}
},
uglify: {
lib: {
options: {
banner: '<%= lib_banner %>'
},
files: {
'build/<%= lib_name %>.min.js': [ '<%= concat.lib.dest %>' ]
}
},
nano: {
options: {
banner: '/* Nano Templates (Tomasz Mazur, Jacek Becela) */ \n'
},
files: {
'build/<%= nano_name %>.min.js': [ 'libs/nano/<%= nano_name %>.js' ]
}
},
base64: {
options: {
banner: '// $Id: base64.js,v 2.15 2014/04/05 12:58:57 dankogai Exp dankogai $\n',
beautify: {
ascii_only: true
}
},
files: {
'build/<%= base64_name %>.min.js': [ 'libs/js-base64/<%= base64_name %>.js' ]
}
}
},
copy: {
css: {
src: 'src/tooltip/css/main.css',
dest: 'build/<%= lib_name %>.css'
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('tooltip', function() {
grunt.file.expand(grunt.config('tooltip.views')).forEach(function(view) {
var ext = view.lastIndexOf('.html'),
last_slash = view.lastIndexOf('/'),
fname = view.substr(last_slash + 1, ext - (last_slash + 1)),
outname = grunt.config('tooltip.output') + '/' + fname + '.js';
grunt.log.write('Saving `' + fname + '` view to ' + outname);
grunt.file.write(outname,
'var ' + fname + '_view = \'' +
grunt.file.read(view).replace(/\s+/g, ' ') +
'\';'
);
});
});
grunt.registerTask('lib', [ 'tooltip', 'concat:lib', 'uglify:lib', 'copy:css' ]);
grunt.registerTask('full', [ 'lib', 'uglify:nano', 'uglify:base64', 'concat:dist', 'concat:mindist' ]);
};