-
Notifications
You must be signed in to change notification settings - Fork 25
/
gruntfile.js
78 lines (76 loc) · 3.47 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
module.exports = function(grunt) {
grunt.initConfig({
// 配置文件,参考package.json配置方式,必须设置项是
// name, version, author
// name作为gallery发布后的模块名
// version是版本,也是发布目录
// author必须是{name: "xxx", email: "xxx"}格式
pkg: grunt.file.readJSON('abc.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd h:MM:ss TT") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// kmc打包任务,默认情况,入口文件是index.js,可以自行添加入口文件,在files下面
// 添加
kmc: {
options: {
packages: [
{
name: '<%= pkg.name %>',
path: '../'
}
],
map: [["<%= pkg.name %>/", "gallery/<%= pkg.name %>/"]]
},
main: {
files: [
{
src: "<%= pkg.version %>/respondtools/index.js",
dest: "<%= pkg.version %>/build/respondtools/index.js"
},
{
src: "<%= pkg.version %>/mediaquerypolyfill/index.js",
dest: "<%= pkg.version %>/build/mediaquerypolyfill/index.js"
},
{
src: "<%= pkg.version %>/picturepolyfill/index.js",
dest: "<%= pkg.version %>/build/picturepolyfill/index.js"
}
]
}
},
// 打包后压缩文件
// 压缩文件和入口文件一一对应
uglify: {
options: {
banner: '<%= banner %>'
},
base: {
files: {
'<%= pkg.version %>/build/respondtools/index-min.js': ['<%= pkg.version %>/build/respondtools/index.js'],
'<%= pkg.version %>/build/mediaquerypolyfill/index-min.js': ['<%= pkg.version %>/build/mediaquerypolyfill/index.js'],
'<%= pkg.version %>/build/picturepolyfill/index-min.js': ['<%= pkg.version %>/build/picturepolyfill/index.js']
}
}
},
cssmin: {
options: {
banner: '/* minified css file */'
},
base: {
files: {
'<%= pkg.version %>/build/responsiveform/formmedia-min.css': ['<%= pkg.version %>/responsiveform/formmedia.css'],
'<%= pkg.version %>/build/responsiveform/formsearch-min.css': ['<%= pkg.version %>/responsiveform/formsearch.css'],
'<%= pkg.version %>/build/responsiveform/iehack.css-min': ['<%= pkg.version %>/responsiveform/iehack.css'],
'<%= pkg.version %>/build/responsiveform/pagestyle-min.css': ['<%= pkg.version %>/responsiveform/pagestyle.css']
}
}
}
});
// 使用到的任务,可以增加其他任务
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-kmc');
grunt.loadNpmTasks('grunt-contrib-cssmin');
return grunt.registerTask('default', ['kmc', 'uglify','cssmin']);
};