Improve assets management
This commit is contained in:
15
Makefile
15
Makefile
@@ -2,23 +2,10 @@ DOCKER_IMAGE := docker.io/kanboard/kanboard
|
|||||||
DOCKER_TAG := master
|
DOCKER_TAG := master
|
||||||
VERSION := $(shell git rev-parse --short HEAD)
|
VERSION := $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
.PHONY: all clean static jshint archive test-sqlite test-mysql test-postgres test-browser \
|
.PHONY: archive test-sqlite test-mysql test-postgres test-browser \
|
||||||
integration-test-mysql integration-test-postgres integration-test-sqlite sql \
|
integration-test-mysql integration-test-postgres integration-test-sqlite sql \
|
||||||
docker-image docker-manifest docker-run docker-sh
|
docker-image docker-manifest docker-run docker-sh
|
||||||
|
|
||||||
all: static
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@ rm -rf ./node_modules
|
|
||||||
|
|
||||||
static: clean
|
|
||||||
@ npm install
|
|
||||||
@ ./node_modules/.bin/gulp vendor js css
|
|
||||||
@ ./node_modules/.bin/jshint assets/js/{core,components,polyfills}
|
|
||||||
|
|
||||||
jshint:
|
|
||||||
@ ./node_modules/.bin/jshint assets/js/{core,components,polyfills}
|
|
||||||
|
|
||||||
archive:
|
archive:
|
||||||
@ echo "Build archive: version=$(VERSION)"
|
@ echo "Build archive: version=$(VERSION)"
|
||||||
@ git archive --format=zip --prefix=kanboard/ $(VERSION) -o kanboard-$(VERSION).zip
|
@ git archive --format=zip --prefix=kanboard/ $(VERSION) -o kanboard-$(VERSION).zip
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ class CssCommand extends BaseCommand
|
|||||||
];
|
];
|
||||||
|
|
||||||
private $vendorFiles = [
|
private $vendorFiles = [
|
||||||
'jquery-ui/jquery-ui.min.css',
|
self::CSS_VENDOR_PATH.'jquery-ui/jquery-ui.min.css',
|
||||||
'jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.css',
|
self::CSS_VENDOR_PATH.'jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.css',
|
||||||
'select2/css/select2.min.css',
|
self::CSS_VENDOR_PATH.'select2/css/select2.min.css',
|
||||||
'font-awesome/css/font-awesome.min.css',
|
self::CSS_VENDOR_PATH.'font-awesome/css/font-awesome.min.css',
|
||||||
'c3/c3.min.css',
|
self::CSS_VENDOR_PATH.'c3/c3.min.css',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
@@ -106,7 +106,9 @@ class CssCommand extends BaseCommand
|
|||||||
{
|
{
|
||||||
$this->minifyFiles(self::CSS_SRC_PATH, $this->appFiles, 'app.min.css');
|
$this->minifyFiles(self::CSS_SRC_PATH, $this->appFiles, 'app.min.css');
|
||||||
$this->minifyFiles(self::CSS_SRC_PATH, $this->printFiles, 'print.min.css');
|
$this->minifyFiles(self::CSS_SRC_PATH, $this->printFiles, 'print.min.css');
|
||||||
$this->minifyFiles(self::CSS_VENDOR_PATH, $this->vendorFiles, 'vendor.min.css');
|
|
||||||
|
$vendorBundle = concat_files($this->vendorFiles);
|
||||||
|
file_put_contents('assets/css/vendor.min.css', $vendorBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function minifyFiles($folder, array $files, $destination)
|
private function minifyFiles($folder, array $files, $destination)
|
||||||
|
|||||||
@@ -79,34 +79,12 @@ class JsCommand extends BaseCommand
|
|||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$appBundle = $this->concat($this->appFiles);
|
$appBundle = concat_files($this->appFiles);
|
||||||
$vendorBundle = $this->concat($this->vendorFiles);
|
$vendorBundle = concat_files($this->vendorFiles);
|
||||||
|
|
||||||
$minifier = new Minify\JS($appBundle);
|
$minifier = new Minify\JS($appBundle);
|
||||||
|
|
||||||
file_put_contents('assets/js/app.min.js', $minifier->minify());
|
file_put_contents('assets/js/app.min.js', $minifier->minify());
|
||||||
file_put_contents('assets/js/vendor.min.js', $vendorBundle);
|
file_put_contents('assets/js/vendor.min.js', $vendorBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function concat(array $files)
|
|
||||||
{
|
|
||||||
$data = '';
|
|
||||||
foreach ($files as $pattern) {
|
|
||||||
foreach (glob($pattern) as $filename) {
|
|
||||||
echo $filename.PHP_EOL;
|
|
||||||
if (! file_exists($filename)) {
|
|
||||||
die("$filename not found\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
$contents = file_get_contents($filename);
|
|
||||||
if ($contents === false) {
|
|
||||||
die("Unable to read $filename\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
$data .= $contents;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,28 @@
|
|||||||
|
|
||||||
use Kanboard\Core\Translator;
|
use Kanboard\Core\Translator;
|
||||||
|
|
||||||
|
function concat_files(array $files)
|
||||||
|
{
|
||||||
|
$data = '';
|
||||||
|
foreach ($files as $pattern) {
|
||||||
|
foreach (glob($pattern) as $filename) {
|
||||||
|
echo $filename.PHP_EOL;
|
||||||
|
if (! file_exists($filename)) {
|
||||||
|
die("$filename not found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$contents = file_get_contents($filename);
|
||||||
|
if ($contents === false) {
|
||||||
|
die("Unable to read $filename\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data .= $contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
function session_get($key)
|
function session_get($key)
|
||||||
{
|
{
|
||||||
return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
|
return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
|
||||||
|
|||||||
10
assets/css/vendor.min.css
vendored
10
assets/css/vendor.min.css
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user