-
Notifications
You must be signed in to change notification settings - Fork 2
/
RoboFile.php
103 lines (85 loc) · 2.42 KB
/
RoboFile.php
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
<?php
class RoboFile extends \Robo\Tasks
{
use Agallou\RoboHash\loadTasks;
public function build()
{
$this->_clean();
$this->_buildCss();
$this->_buildJs();
}
protected function _buildCss()
{
$this->say("Starting CSS rebuild");
$this
->taskScss(['ressources/sass/main.scss' => 'cache/assets/sass/main_sass.css'])
->addImportPath('ressources/sass/')
->run()
;
$this
->taskConcat([
'vendor/bower-asset/highlightjs/styles/railscasts.css',
'cache/assets/sass/main_sass.css',
])
->to('cache/main.css')
->run()
;
$this
->taskMinify('cache/main.css')
->to('cache/main.css')
->run()
;
$this->taskHash('cache/main.css')->to('source/assets/css/')->run();
$this->say("CSS rebuilt successfully!");
}
protected function _buildJs()
{
$this->say("Starting JS rebuild");
$types = [
'critical' => [
'vendor/bower-asset/lazyload/build/lazyload.js',
],
'main' => [
'vendor/bower-asset/highlightjs/highlight.pack.js',
'ressources/js/main.js',
],
];
foreach ($types as $type => $files) {
$this
->taskConcat($files)
->to($cacheFile = sprintf('source/assets/js/%s.js', $type))
->run()
;
$this
->taskMinify($cacheFile)
->keepImportantComments(false)
->to($webFile = sprintf('source/assets/js/%s.js', $type))
->run()
;
$this->taskHash($webFile)->to('source/assets/js/')->run();
}
$this->say("JS rebuilt successfully!");
}
protected function _clean()
{
$this->_mkdir('cache/');
$this->_cleanBase();
$this->_cleanCss();
$this->_cleanJs();
}
protected function _cleanBase()
{
$this->_cleanDir('cache/');
}
protected function _cleanCss()
{
$this->_mkdir('source/assets/css');
$this->_cleanDir('source/assets/css');
$this->_mkdir('cache/assets/sass');
}
protected function _cleanJs()
{
$this->_mkdir('source/assets/js');
$this->_cleanDir('source/assets/js');
}
}