This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
169 lines (164 loc) · 3.66 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
/*jshint es3:false */
module.exports = function(grunt) {
// All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'js/**/*.js'],
options: {
// http://www.jshint.com/docs/options/
ignores: ['js/vendor/**/*.js'],
smarttabs: true,
trailing: true,
noempty: true,
es3: true,
unused: true,
undef: 'vars',
eqnull: true,
browser: true,
devel: true,
globals: {
jquery: true,
module: false,
require: false,
define: false,
}
}
},
concat: {
vendorCommon: {
src: [
'public/js/vendor/jquery-1.11.1.js',
'public/js/vendor/bootstrap.js',
'public/js/vendor/underscore.js',
'public/js/vendor/typeahead.bundle.js',
'public/js/vendor/masonry.pkgd.js'
],
dest: 'public/js/vendor-common.min.js'
},
homeCommon: {
src: [
'public/js/home/config.js',
'public/js/home/lang.js',
'public/js/home/headerQuickSearch.js',
'public/js/home/comment.js'
],
dest: 'public/js/home-common.min.js'
}
},
uglify: {
options: {
// Put a banner on each uglified file
banner: '/*! <%= pkg.description %> - <%= grunt.template.today("ddd, mmm d, yyyy, h:MM:ss Z") %> */\n',
sourceMap: true,
mangle: {
except: ['jQuery']
},
compress: {
drop_console: true
}
},
build: {
files: {
'public/js/vendor-common.min.js': ['public/js/vendor-common.min.js'],
'public/js/home-common.min.js': ['public/js/home-common.min.js']
}
}
},
imagemin: {
png: {
options: {
optimizationLevel: 7,
pngquant: true
},
files: [{
expand: true,
cwd: 'public/img/',
src: ['**/*.png'],
dest: 'public/img/',
ext: '.png'
}]
},
// jpg: {
// options: {
// progressive: true
// },
// files: [{
// expand: true,
// cwd: 'public/img/',
// src: ['**/*.jpg'],
// dest: 'public/img2/',
// ext: '.jpg'
// }]
// }
},
less: {
development: {
options: {
paths: ['less'],
compress: true,
strictMath: false,
strictUnits: false,
sourceMap: true,
sourceMapRootpath: '../..'
},
files: {
'public/css/default.css': 'less/default.less',
'public/css/error.css': 'less/error.less',
'public/css/login.css': 'less/login.less'
}
},
production: {
options: {
paths: ['less'],
cleancss: true,
strictMath: false,
strictUnits: false,
report: 'min'
},
files: {
'public/css/default.css': 'less/default.less',
'public/css/error.css': 'less/error.less',
'public/css/login.css': 'less/login.less'
}
}
},
watch: {
options: {
livereload: true
},
images: {
files: ['public/img/**/*.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: false
}
},
styles: {
files: ['less/**/*.less'],
tasks: ['less:development'],
options: {
spawn: true
}
},
scripts: {
files: ['public/js/**/*.js'],
tasks: ['concat'],
options: {
spawn: true
}
}
}
});
// Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
// Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['watch']);
grunt.registerTask('prod', ['concat', 'uglify', 'imagemin', 'less:production']);
grunt.registerTask('js', ['concat', 'uglify']);
};