-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
116 lines (105 loc) · 2.34 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
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// js minification
uglify: {
dist: {
files: {
// admin scripts
'lib/js/min/yikes-full-page-search.min.js': [ // all other admin scripts
'lib/js/yikes-full-page-search.js',
],
}
}
},
// Autoprefixer for our CSS files
postcss: {
options: {
map: true,
processors: [
require('autoprefixer-core') ({
browsers: ['last 2 versions']
})
]
},
dist: {
src: ['lib/css/*.css']
}
},
auto_install: {
local: {}
},
// css minify all contents of our directory and add .min.css extension
cssmin: {
target: {
files: [
// admin css files
{
'lib/css/min/yikes-full-page-search.min.css':
[
'lib/css/yikes-full-page-search.css',
],
}
]
}
},
// Generate a nice banner for our css/js files
usebanner: {
taskName: {
options: {
position: 'top',
replace: true,
banner: '/*\n'+
' * @Plugin <%= pkg.title %>\n' +
' * @Author <%= pkg.author %>\n'+
' * @Site <%= pkg.site %>\n'+
' * @Version <%= pkg.version %>\n' +
' * @Build <%= grunt.template.today("mm-dd-yyyy") %>\n'+
' */',
linebreak: true
},
files: {
src: [
'lib/css/min/*.min.css',
'lib/js/min/*.min.js',
]
}
}
},
// watch our project for changes
watch: {
admin_css: { // admin css
files: 'lib/css/*.css',
tasks: ['cssmin', 'usebanner'],
options: {
spawn: false,
event: ['all']
},
},
admin_js: { // admin js
files: 'lib/js/*.js',
tasks: ['uglify', 'usebanner'],
options: {
spawn: false,
event: ['all']
},
},
},
});
// load tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-postcss'); // CSS autoprefixer plugin (cross-browser auto pre-fixes)
grunt.loadNpmTasks('grunt-auto-install'); // autoload all of ourd ependencies (ideally, you install this one package, and run grunt auto_install to install our dependencies automagically)
// register task
grunt.registerTask('default', [
'uglify',
'postcss',
'cssmin',
'usebanner',
'watch',
]);
};