further conversion to makefile build
This commit is contained in:
parent
16a4a2556b
commit
78ced31e9d
13
Makefile
13
Makefile
@ -31,7 +31,18 @@ clean:
|
|||||||
|
|
||||||
bindata.go: client client/*
|
bindata.go: client client/*
|
||||||
rm -fr ./clientpack
|
rm -fr ./clientpack
|
||||||
php ./clientpack.php
|
cp -r ./client ./clientpack
|
||||||
|
sed -i -re 's~//IIFEMODE:~~g' clientpack/dcwebui.js
|
||||||
|
uglifyjs clientpack/dcwebui.js -o clientpack/dcwebui.min.js -c -m
|
||||||
|
lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css
|
||||||
|
#php ./clientpack.php
|
||||||
|
./minipack clientpack/index.htm css dcwebui.css clientpack/dcwebui.min.css
|
||||||
|
./minipack clientpack/index.htm js dcwebui.js clientpack/dcwebui.min.js
|
||||||
|
./minipack clientpack/index.htm js socket.io-1.7.2.js clientpack/socket.io-1.7.2.js
|
||||||
|
html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm
|
||||||
|
mv clientpack/index.min.htm clientpack/index.htm
|
||||||
|
rm ./clientpack/*.js
|
||||||
|
rm ./clientpack/*.css
|
||||||
go-bindata -nomemcopy -prefix clientpack clientpack
|
go-bindata -nomemcopy -prefix clientpack clientpack
|
||||||
|
|
||||||
$(BINNAME).exe: bindata.go *.go
|
$(BINNAME).exe: bindata.go *.go
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
# Dependencies:
|
|
||||||
# - PHP
|
|
||||||
# - Uglifyjs (`npm install -g uglify-js`)
|
|
||||||
# - Lessc (`npm install -g less`)
|
|
||||||
# - Lessc minifier (`npm install -g less-plugin-clean-css`)
|
|
||||||
# - HTML minifier (`npm install -g html-minifier`)
|
|
||||||
|
|
||||||
echo "Compressing/minifying web resources...\n";
|
|
||||||
|
|
||||||
if (is_dir('clientpack')) {
|
|
||||||
`rm -r clientpack`;
|
|
||||||
}
|
|
||||||
|
|
||||||
`cp -r client clientpack`;
|
|
||||||
|
|
||||||
// Toggle IIFE on
|
|
||||||
|
|
||||||
`sed -i -re 's~//IIFEMODE:~~g' clientpack/dcwebui.js`;
|
|
||||||
|
|
||||||
// Minify JS
|
|
||||||
|
|
||||||
`uglifyjs clientpack/dcwebui.js -o clientpack/dcwebui.min.js -c -m`;
|
|
||||||
|
|
||||||
// Minify CSS
|
|
||||||
|
|
||||||
`lessc --clean-css clientpack/dcwebui.css clientpack/dcwebui.min.css`;
|
|
||||||
|
|
||||||
// Embed css into HTML file
|
|
||||||
|
|
||||||
$html_content = file_get_contents('clientpack/index.htm');
|
|
||||||
|
|
||||||
$html_content = preg_replace_callback('~<link[^>]+dcwebui.css[^>]*>~', function() { return '<style type="text/css">'.file_get_contents('clientpack/dcwebui.min.css').'</style>'; }, $html_content);
|
|
||||||
|
|
||||||
// Embed JS into HTML file
|
|
||||||
|
|
||||||
$html_content = preg_replace_callback('~<script[^>]+dcwebui.js[^>]*>~', function() { return '<script type="text/javascript">'.file_get_contents('clientpack/dcwebui.min.js').'</script>'; }, $html_content);
|
|
||||||
|
|
||||||
// Embed socketio into HTML file
|
|
||||||
|
|
||||||
define('SIO_NAME', 'socket.io-1.7.2.js');
|
|
||||||
$html_content = preg_replace_callback('~<script[^>]+'.SIO_NAME.'[^>]*>~', function() { return '<script type="text/javascript">'.file_get_contents('clientpack/'.SIO_NAME).'</script>'; }, $html_content);
|
|
||||||
|
|
||||||
// Minify the combined file
|
|
||||||
|
|
||||||
file_put_contents('clientpack/index.htm', $html_content);
|
|
||||||
|
|
||||||
`html-minifier --collapse-whitespace -o clientpack/index.min.htm clientpack/index.htm`;
|
|
||||||
|
|
||||||
// Clean up files
|
|
||||||
|
|
||||||
unlink('clientpack/index.htm');
|
|
||||||
unlink('clientpack/dcwebui.js');
|
|
||||||
unlink('clientpack/dcwebui.min.js');
|
|
||||||
unlink('clientpack/dcwebui.css');
|
|
||||||
unlink('clientpack/dcwebui.min.css');
|
|
||||||
unlink('clientpack/'.SIO_NAME);
|
|
||||||
rename('clientpack/index.min.htm', 'clientpack/index.htm');
|
|
23
minipack
Executable file
23
minipack
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Embed content into HTML file
|
||||||
|
function embed($filename, $mode, $find, $sourcefile) {
|
||||||
|
$html_content = file_get_contents($filename);
|
||||||
|
$modes = [
|
||||||
|
'js' => ['script', 'script'],
|
||||||
|
'css' => ['link', 'style'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$html_content = preg_replace_callback(
|
||||||
|
'~<'. $modes[$mode][0] .'[^>]+'.$find.'[^>]*>~',
|
||||||
|
function() use ($modes, $mode, $sourcefile) {
|
||||||
|
return '<'. $modes[$mode][1] . '>'.file_get_contents($sourcefile).'</'. $modes[$mode][1] .'>';
|
||||||
|
},
|
||||||
|
$html_content
|
||||||
|
);
|
||||||
|
|
||||||
|
file_put_contents($filename, $html_content);
|
||||||
|
}
|
||||||
|
|
||||||
|
embed($_SERVER['argv'][1], $_SERVER['argv'][2], $_SERVER['argv'][3], $_SERVER['argv'][4]);
|
Loading…
Reference in New Issue
Block a user