/
01-compress-js-css.xml
75 lines (69 loc) · 2.85 KB
/
01-compress-js-css.xml
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
<?xml version="1.0"?>
<!--
/**
* Copyright 2006 - 2016 TubePress LLC (http://tubepress.com)
*
* This file is part of TubePress (http://tubepress.com)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-->
<project>
<macrodef name="compress-css">
<sequential>
<__npm-install />
<__save-dev-copies list-of-files="config/css-to-compress.txt" extension=".css" />
<apply executable="../../../../node_modules/.bin/uglifycss" parallel="false" dir="target/stage/tubepress" relative="true"
failonerror="true">
<fileset dir="target/stage/tubepress/" includesfile="config/css-to-compress.txt"/>
<redirector>
<outputmapper>
<mapper type="glob" from="*" to="target/stage/tubepress/*"/>
</outputmapper>
</redirector>
</apply>
</sequential>
</macrodef>
<macrodef name="compress-js">
<sequential>
<__npm-install />
<__save-dev-copies list-of-files="config/js-to-compress.txt" extension=".js" />
<apply executable="../../../../node_modules/.bin/uglifyjs" parallel="false" dir="target/stage/tubepress" relative="true"
failonerror="true">
<fileset dir="target/stage/tubepress/" includesfile="config/js-to-compress.txt"/>
<srcfile />
<arg value="--mangle" />
<arg value="--compress" />
<arg value="--comments" />
<arg value="sequences,unsafe,conditionals,comparisons,booleans,loops,if_return,join_vars,cascade" />
<redirector>
<outputmapper>
<mapper type="glob" from="*" to="target/stage/tubepress/*"/>
</outputmapper>
</redirector>
</apply>
</sequential>
</macrodef>
<macrodef name="__npm-install">
<sequential>
<log msg="Installing npm modules" />
<exec executable="npm" failonerror="true" dir="../">
<arg value="install" />
<arg value="--silent" />
</exec>
</sequential>
</macrodef>
<macrodef name="__save-dev-copies">
<attribute name="list-of-files" />
<attribute name="extension" />
<sequential>
<log msg="Saving dev copies of files in @{list-of-files}" />
<copy todir="target/stage/tubepress">
<fileset dir="target/stage/tubepress/" includesfile="@{list-of-files}"/>
<mapper type="glob" from="*@{extension}" to="*-dev@{extension}" />
</copy>
</sequential>
</macrodef>
</project>