-
Notifications
You must be signed in to change notification settings - Fork 79
/
Gruntfile.js
77 lines (73 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
/*global module:false*/
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ["dist", "temp"],
concat: {
dist: {
src: ['src/core.js', 'src/lang.js', 'src/main.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
dist: {
options: {
banner: "/*! xhEditor v<%= pkg.version %> | (c) 2009, 2013 xheditor.com.\r\nLicence: http://xheditor.com/license/lgpl.txt */\n",
beautify: {
ascii_only: true
}
},
files: {
'dist/<%= pkg.name %>-<%= pkg.version %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
copy: {
release: {
options: {
processContentExclude: ['**/*.gif','**/*.png','**/*.swf'],
processContent: function(content, filename){
var pkg = grunt.config( "pkg" );
if(/\.min\.js$/i.test(filename)){
content = content.replace(/@VERSION/g,pkg.version);
content = content.replace(/@BUILDDATE/g,grunt.template.today("yymmdd"));
}
else if(/\.html$/i.test(filename)){
content = content.replace(/xheditor\.js"/g, pkg.name + '-' + pkg.version + '.min.js"');
}
return content;
}
},
files: [
{src: ['dist/<%= pkg.name %>-<%= pkg.version %>.min.js'], dest: 'temp/xheditor-<%= pkg.version %>/<%= pkg.name %>-<%= pkg.version %>.min.js'},
{expand: true, src:['xheditor_lang/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['xheditor_skin/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['xheditor_emot/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['xheditor_plugins/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['demos/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['jquery/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['serverscript/**'], dest: 'temp/xheditor-<%= pkg.version %>/'},
{expand: true, src:['CHANGE.md', 'LGPL-LICENSE.txt', 'README.md', 'THANKS.md', 'TODO.md', 'wizard.html'], dest: 'temp/xheditor-<%= pkg.version %>/'}
]
}
},
compress: {
'zip': {
options: {
archive: 'release/<%= pkg.name %>-<%= pkg.version %>.zip'
},
files: [
{expand:true, cwd: 'temp', src: ['xheditor-<%= pkg.version %>/**'], dest: '/'},
]
}
}
});
// Default task.
grunt.registerTask('default', ['clean', 'concat', 'uglify', 'copy', 'compress',]);
};