forked from wangeditor-team/wangEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·145 lines (133 loc) · 3.31 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
// 包装函数
module.exports = function(grunt) {
// 任务配置,所有插件的配置信息
grunt.initConfig({
//获取 package.json 的信息
pkg: grunt.file.readJSON('package.json'),
// uglify插件的配置信息
uglify: {
options: {
stripBanners: true,
banner: '/*! <%=pkg.name%>-<%=pkg.version%>.js <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/js/<%=pkg.name%>.js',
dest: 'dist/js/<%=pkg.name%>.min.js'
},
buildVersion: {
src: 'src/js/<%=pkg.name%>.js',
dest: 'dist/js/<%=pkg.name%>-<%=pkg.version%>.min.js'
}
},
//less插件的配置信息
less: {
editorBuild: {
src: 'src/css/parts/wangEditor.less',
dest: 'src/css/parts/wangEditor.css'
},
modalBuild: {
src: 'src/css/parts/modal.less',
dest: 'src/css/parts/modal.css'
}
},
//jshint插件的配置信息'
jshint:{
build: [ 'Gruntfile.js', 'src/js/*.js' ],
options: {
jshintrc: '.jshintrc'
}
},
//concat插件的配置信息
concat: {
css:{
src: 'src/css/parts/*.css',
dest: 'src/css/<%=pkg.name%>.css'
},
cssVersion:{
src: 'src/css/parts/*.css',
dest: 'src/css/<%=pkg.name%>-<%=pkg.version%>.css'
},
menus:{
src: 'src/js/parts/11-fn-menus/*.js',
dest: 'src/js/parts/11-fn-menus.js'
},
build:{
src: 'src/js/parts/*.js',
dest: 'src/js/<%=pkg.name%>.js'
},
buildVersion:{
src: 'src/js/parts/*.js',
dest: 'src/js/<%=pkg.name%>-<%=pkg.version%>.js'
}
},
//copy插件的配置信息
copy: {
main: {
files:[
//js
{
expand: true,
flatten: true,
src: ['src/js/*.js'],
dest: 'dist/js/',
filter: 'isFile'
},
//css
{
expand: true,
flatten: true,
src: ['src/css/*.css'],
dest: 'dist/css/',
filter: 'isFile'
}
]
}
},
// watch插件的配置信息
watch: {
js: {
files: [
'src/js/parts/*.js',
'src/js/parts/11-fn-menus/*.js'
],
tasks: [
'concat',
'jshint',
'uglify',
'copy'
],
options: { spawn: false}
},
css:{
files: [
'src/css/parts/*.less',
'src/css/fontIcon.css',
'src/css/wangEditor-hack.css'
],
tasks: [
'less',
'concat',
'copy'
],
options: { spawn: false}
}
}
});
// 告诉grunt我们将使用插件
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
// 告诉grunt当我们在终端中输入grunt时需要做些什么(注意先后顺序)
grunt.registerTask('default', [
//注意下面注册任务时的前后顺序
'less',
'concat',
'jshint',
'uglify',
'copy',
'watch'
]);
};