-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathGruntfile.js
87 lines (86 loc) · 1.93 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
/*
* Created with Sublime Text 2.
* User: 田想兵
* Date: 2015-03-26
* Time: 14:11:42
* Contact: [email protected]
*/
var fs = require("fs");
var path = require("path");
module.exports = function(grunt) {
var today = new Date();
var config = {
version: [today.getFullYear(), today.getMonth() + 1, today.getDate(), today.getTime()].join('.'),
pkg: grunt.file.readJSON('package.json')
};
config.publishVersion = config.pkg.version;
config.uglify = {
options: {
banner: '/*! <%= pkg.name %> author:<%=pkg.family%> email:<%=pkg.author.email%>\n* demo:<%=pkg.author.url%> \n* git:<%=pkg.git%> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
// src: ['src/<%= pkg.name %>.js', '!*.min.js'],
// dest: 'dist/<%= pkg.name %>.min.js'
files:[{
expand:true,
cwd:"src",
src:['*.js', '!*.min.js'],
dest:"dist",
ext:'.min.js'
}]
},
publish:{
src:['src/mobile-select-area.js'],
dest:'mobile-select-area.js'
}
};
config.cssmin = {
options: {
compatibility: 'ie8', //设置兼容模式
noAdvanced: true //取消高级特性
},
target: {
files: [{
expand: true,
cwd: 'src',
src: ['*.css', '!*.min.css'],
dest: 'dist',
ext: '.min.css'
}]
}
};
config.copy = {
main: {
expand: true,
cwd: 'src/',
src: ['*.js', '*.css'],
dest: 'dist/',
flatten: true,
filter: 'isFile',
},
};
config.watch={
scripts:{
files:['src/**.*'],
tasks:['default'],
options:{
livereload: true
}
},
html:{
files:['example/**.*'],
tasks:['default'],
options:{
livereload: true
}
}
};
grunt.initConfig(config);
// 加载包含 "uglify" 任务的插件。
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
// 默认被执行的任务列表。
grunt.registerTask('default', ['uglify', 'cssmin', 'copy']);
};