-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
173 lines (148 loc) · 3.84 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
170
171
172
173
module.exports = function(grunt) {
// Display the elapsed execution time of grunt tasks
require('time-grunt')(grunt);
// A JIT(Just In Time) plugin - task loader
require('jit-grunt')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// folder containing resources
resourceDirectory: 'public',
// CSS source files
cssSourceFile: {
front: '<%= resourceDirectory %>/scss/front.scss',
print: '<%= resourceDirectory %>/scss/print.scss'
},
// CSS source files
jsSourceFile: {
front: '<%= resourceDirectory %>/js/front.js'
},
// compiled CSS files
cssFile: {
front: '<%= resourceDirectory %>/css/front.css',
frontMin: '<%= resourceDirectory %>/css/front.min.css',
print: '<%= resourceDirectory %>/css/print.css',
printMin: '<%= resourceDirectory %>/css/print.min.css'
},
// compiled JS files
jsFile: {
frontMin: '<%= resourceDirectory %>/js/front.min.js'
},
// paired front.css files with source files
cssPair: {
'<%= cssFile.front %>': '<%= cssSourceFile.front %>',
'<%= cssFile.print %>': '<%= cssSourceFile.print %>'
},
// paired front.min.css files with source files
cssPairMin: {
'<%= cssFile.frontMin %>': '<%= cssSourceFile.front %>',
'<%= cssFile.printMin %>': '<%= cssSourceFile.print %>'
},
banner: '/*! <%= grunt.template.today("yyyy-mm-dd") %> */\n\n',
/**
* SCSS file compilation
*/
sass: {
// compilation for development, uncompressed with source map
develop: {
files: '<%= cssPair %>',
options: {
style: 'expanded'
}
},
// compilation for production, compressed
production: {
files: '<%= cssPairMin %>',
options: {
style: 'compressed',
sourcemap: 'none'
},
},
},
/**
* Count CSS selectors
*/
csscount: {
dev: {
src: [
'<%= cssFile.front %>'
],
options: {
maxSelectors: 4096,
beForgiving: true
}
}
},
/**
* Creates githooks for post-merge and post-checkout
*/
githooks: {
all: {
// generates git hook that runs build task after every merge or pull
'post-merge': 'build',
'post-checkout': 'build',
}
},
/**
* Run predefined tasks whenever watched file patterns are added, changed or deleted
*/
watch: {
options: {
nospawn: true
},
styles: {
files: [
'<%= resourceDirectory %>/scss/**/*.scss'
],
tasks: [
'sass:develop'
],
},
scripts: {
files: [
'<%= jsSourceFile.front %>'
],
tasks: [
'uglify'
],
}
},
// JS
uglify: {
options: {
banner: '/*' + ' Generated: <%= grunt.template.today("dd.mm.yyyy HH:MM:ss") %>' + ' */\n'
},
my_target: {
options: {
sourceMap: false
},
files: {
'<%= jsFile.frontMin %>': [
'<%= resourceDirectory %>/js/vendor/jquery-3.2.0.min.js',
'<%= resourceDirectory %>/js/vendor/jquery.ba-throttle-debounce.min.js',
'<%= resourceDirectory %>/js/vendor/bootstrap.min.js',
'<%= resourceDirectory %>/js/vendor/bootstrap-datepicker.js',
'<%= resourceDirectory %>/js/vendor/bootstrap-datepicker.cs.js',
'<%= jsSourceFile.front %>'
]
}
}
},
});
grunt.loadNpmTasks('grunt-css-count');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('build', [
'sass:develop',
'uglify'
]);
grunt.registerTask('build-production', [
'sass:develop',
'sass:production',
'uglify'
]);
grunt.registerTask('default', [
'watch'
]);
grunt.registerTask('count', [
'csscount'
]);
};