-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
105 lines (91 loc) · 3.18 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
/*!
* Ratchet's Gruntfile
* http://goratchet.com
* Copyright 2015 Connor Sears
* Licensed under MIT (https://github.com/twbs/ratchet/blob/master/LICENSE)
*/
/* jshint node: true */
module.exports = function (grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
RegExp.quote = function (string) {
return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
};
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
distPath: 'dist/',
jsPath: 'src/'
},
banner: '/*!\n' +
' * =============================================================\n' +
' * ReactOO v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license %> (https://github.com/mazong1123/reactoo/blob/master/LICENSE)\n' +
' *\n' +
' * v<%= pkg.version %> designed by @mazong1123.\n' +
' * =============================================================\n' +
' */\n',
clean: {
dist: ['<%= meta.distPath %>']
},
copy: {
all: {
expand: true,
cwd: 'src/',
src: '**',
dest: '<%= meta.distPath %>'
}
},
uglify: {
options: {
banner: '<%= banner %>',
compress: {
warnings: false
},
mangle: true,
preserveComments: false
},
reatoo: {
files: [{
src: '<%= meta.distPath %><%= pkg.name %>.js',
dest: '<%= meta.distPath %><%= pkg.name %>.min.js'
}]
}
},
sed: {
versionNumber: {
pattern: (function () {
var old = grunt.option('oldver');
return old ? RegExp.quote(old) : old;
})(),
replacement: grunt.option('newver'),
exclude: [
'dist/fonts',
'docs/assets',
'fonts',
'node_modules'
],
recursive: true
}
},
qunit: {
all: ['tests/*.html']
}
});
// Load the plugins
require('load-grunt-tasks')(grunt, { scope: 'devDependencies' });
require('time-grunt')(grunt);
// Default task(s).
grunt.registerTask('dist-js', ['uglify']);
grunt.registerTask('dist', ['clean', 'copy', 'dist-js', 'qunit']);
grunt.registerTask('test', ['qunit']);
grunt.registerTask('default', ['dist']);
// Version numbering task.
// grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
// This can be overzealous, so its changes should always be manually reviewed!
grunt.registerTask('change-version-number', 'sed');
};