-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
217 lines (191 loc) · 5.71 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
module.exports = function (grunt) {
// Initialize configuration object
grunt.initConfig({
// Read in project settings
pkg: grunt.file.readJSON('package.json'),
// User editable project settings & variables
options: {
// Base path to your assets folder
base: 'app/assets',
// Published assets path
publish: 'public/assets',
// Files to be clean on rebuild
clean: {
all: ['<%= options.css.concat %>', '<%= options.css.min %>', '<%= options.less.compiled %>', '<%= options.sass.compiled %>', '<%= options.stylus.compiled %>', '<%= options.js.min %>', '<%= options.js.concat %>', '<%= options.less.compiled %>'],
concat: ['<%= options.css.concat %>', '<%= options.js.concat %>']
},
// CSS settings
css: {
base: 'app/assets/css', // Base path to your CSS folder
files: ['app/assets/css/less.css'], // CSS files in order you'd like them concatenated and minified
concat: '<%= options.css.base %>/concat.css', // Name of the concatenated CSS file
min: '<%= options.publish %>/style.min.css' // Name of the minified CSS file
},
// JavaScript settings
js: {
base: 'app/assets/js', // Base path to you JS folder
files: ['app/assets/js/bootstrap.js','app/assets/js/restfulizer.js','app/assets/js/selectize.js'], // JavaScript files in order you'd like them concatenated and minified
concat: '<%= options.js.base %>/concat.js', // Name of the concatenated JavaScript file
min: '<%= options.publish %>/script.min.js' // Name of the minified JavaScript file
},
// LESS Settings
less: {
base: 'app/assets/less', // Base path to you LESS folder
file: 'app/assets/less/master.less', // LESS file (ideally, one file which contains imports)
compiled: '<%= options.css.base %>/less.css' // Name of the compiled LESS file
},
// SASS Settings
sass: {
base: 'assets/sass', // Base path to you SASS folder
file: 'assets/sass/main.sass', // SASS file (ideally, one file which contains imports)
compiled: '<%= options.css.base %>/sass.css' // Name of the compiled SASS file
},
// STYLUS Settings
stylus: {
base: 'assets/stylus', // Base path to you STYLUS folder
file: 'assets/stylus/main.stylus', // STYLUS file (ideally, one file which contains imports)
compiled: '<%= options.css.base %>/stylus.css' // Name of the compiled STYLUS file
},
// Notification messages
notify: {
watch: {
title: 'Live Reloaded!',
message: 'Files were modified, recompiled and site reloaded'
}
},
// Files and folders to watch for live reload and rebuild purposes
watch: {
files: ['<%= options.js.files %>', '<%= options.css.files %>', '<%= options.less.base %>/*.less',
'<%= options.sass.base %>/*.sass', '<%= options.stylus.base %>/*.styl',
'!<%= option.js.min %>', '!<%= options.less.compiled %>', '!<%= options.sass.compiled %>', '!<%= options.stylus.compiled %>']
}
},
// Clean files and folders before replacement
clean: {
all: {
src: '<%= options.clean.all %>'
},
concat: {
src: '<%= options.clean.concat %>'
}
},
// Concatenate multiple sets of files
concat: {
css: {
files: {
'<%= options.css.concat %>' : ['<%= options.css.files %>']
}
},
js: {
options: {
block: true,
line: true,
stripBanners: true
},
files: {
'<%= options.js.concat %>' : '<%= options.js.files %>',
}
}
},
// Minify and concatenate CSS files
cssmin: {
minify: {
src: '<%= options.css.concat %>',
dest: '<%= options.css.min %>'
}
},
// Javascript linting - JS Hint
jshint: {
files: ['<%= options.js.files %>'],
options: {
// Options to override JSHint defaults
curly: true,
indent: 4,
trailing: true,
devel: true,
globals: {
jQuery: true
}
}
},
// Compile LESS files
less: {
main: {
options: {
yuicompress: true,
ieCompat: true
},
files: {
'<%= options.less.compiled %>': '<%= options.less.file %>'
}
}
},
// Compile SASS files
sass: {
main: {
files: {
'<%= options.sass.compiled %>': '<%= options.sass.file %>'
}
}
},
// Compile STYLUS files
stylus: {
main: {
files: {
'<%= options.stylus.compiled %>': '<%= options.stylus.file %>'
}
}
},
// Display notifications
notify: {
watch: {
options: {
title: '<%= options.notify.watch.title %>',
message: '<%= options.notify.watch.message %>'
}
}
},
// Javascript minification - uglify
uglify: {
options: {
preserveComments: false
},
files: {
src: '<%= options.js.concat %>',
dest: '<%= options.js.min %>'
}
},
// Watch for files and folder changes
watch: {
options: {
livereload: true
},
files: '<%= options.watch.files %>',
tasks: ['default', 'notify:watch']
},
phpcsfixer: {
app: {
dir: 'app'
},
options: {
bin: '/usr/local/bin/php-cs-fixer',
}
},
});
// Load npm tasks
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-livereload');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-php-cs-fixer');
// Register tasks
grunt.registerTask('default', ['clean:all', 'less', 'concat:css', 'concat:js', 'cssmin', 'uglify', 'clean:concat', 'phpcsfixer']); // Default task
}