-
Notifications
You must be signed in to change notification settings - Fork 18
/
Gruntfile.js
executable file
·171 lines (156 loc) · 3.88 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* jshint node: true */
var exec = require("child_process").exec;
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*dpl started*/',
distRoot: grunt.option('target') || '.package',
docsRoot: 'docs',
jshint: {
options: {
jshintrc: 'js/.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
src: {
src: ['js/*.js']
},
test: {
src: ['js/tests/unit/*.js']
}
},
browserify: {
build: {
files: {
'<%= distRoot %>/js/<%= pkg.name %>.js': ['js/<%= pkg.name %>.js'],
}
}
},
uglify: {
build: {
options: {
sourceMap: true
},
files: [{
expand: true,
cwd: '<%= distRoot %>/js/',
src: ['**/*.js', '!*.min.js'],
dest: '<%= distRoot %>/js/',
ext: '.min.js'
}]
}
},
less: {
options: {
compile: true
},
sui: {
src: ['less/<%= pkg.name %>.less'],
dest: '<%= distRoot %>/css/<%= pkg.name %>.css'
},
suiMin: {
options: {
compress: true
},
src: ['less/<%= pkg.name %>.less'],
dest: '<%= distRoot %>/css/<%= pkg.name %>.min.css'
},
docs: {
files: [{
expand: true,
cwd: '<%= docsRoot %>/assets/less/',
src: ['**/*.less'],
dest: '<%= docsRoot %>/assets/css/',
ext: '.css'
}]
}
},
jade: {
docs: {
options: {
pretty: true
},
files: [
{
expand: true,
cwd: '<%= docsRoot %>/templates',
src: ['**/*.jade', '!base.jade', '!sidenav.jade', '!header.jade', '!com-*', '!*-com.jade', '!discuss.jade', '!foot.jade', '!head.jade'],
dest: '<%= docsRoot %>',
ext: '.html'
},
],
}
},
copy: {
fonts: {
files: [
{ expand: true, src: ['./fonts/*'], dest: '<%= distRoot %>/' },
]
}
},
/*
qunit: {
options: {
inject: 'js/tests/unit/phantom.js'
},
files: ['js/tests/*.html']
},
*/
connect: {
server: {
options: {
port: 3000,
base: '.'
}
}
},
watch: {
options: {
livereload: 3456
},
css: {
files: 'less/*.less',
tasks: ['less:sui', 'newer:copy']
},
js: {
files: 'js/*.js',
tasks: ['browserify', 'newer:copy']
},
docs: {
files: '<%= docsRoot %>/templates/**/*.jade',
tasks: ['newer:jade:docs']
},
docsCss: {
files: '<%= docsRoot %>/assets/less/**/*.less',
tasks: ['newer:less:docs']
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-newer');
// Test task.
grunt.registerTask('test', ['jshint']);
// JS distribution task.
grunt.registerTask('dist-js', ['browserify', 'uglify']);
// CSS distribution task.
grunt.registerTask('dist-css', ['less']);
// CSS distribution task.
grunt.registerTask('dist-fonts', ['copy:fonts']);
// Full distribution task.
grunt.registerTask('dist', ['dist-css', 'dist-js', 'dist-fonts']);
grunt.registerTask('docs', ['jade']); //必须先执行dist才能执行此任务
// Default task.
grunt.registerTask('default', ['test', 'dist', 'docs']);
//local server and watch
grunt.registerTask('local',['connect','watch']);
}