devfactorych / minify Goto Github PK
View Code? Open in Web Editor NEWThis project forked from ceesvanegmond/minify
A PHP package for minifying your .css and .js.
License: MIT License
This project forked from ceesvanegmond/minify
A PHP package for minifying your .css and .js.
License: MIT License
I tried using this package, but it doesn't seem to work. It loads the files fine locally, but when I take local
out of ignore_environments
, nothing happens. It does not build the files that it should. Do I need to run a command to have it build the files?
when minifying css, properties which use a variable are removed.
installed package in my project and added service provider and Facade in config/app.php after that i ran command php artisan vendor:publish and published - Provider: Devfactory\Minify\MinifyServiceProvider in public css i added folder 'builds' with rights 775 in my blade i added {!! Minify::stylesheet(['/front/assets/css/base.css']) !!} but its not minifying files
php 7.1.3 laravel 5.6
I have a lot of .js files that are shared across two different websites. The .js files are placed in a directory outside the Laravel folder. With a virtual directory link the .js assets can be retrieved by url.
I was looking for a way to minify and return these files by specifying a relative path to the original files but it generates an url that is incompatible with my virtual directory link.
For example this is what I have tried.
{!! Minify::javascript('\..\..\..\shared_js\createjs\game.js') !!}
The same file can be retrieved directly by this url:
\js\shared_js\createjs\game.js
Do you know if this is possible?
Hello, first I want to say that I love this lib, it is simple, pragmatic, and does the job exactly as I want. Thank you!
But it appears that it breaks base64 encoded images, for example I have:
background-image: url("data:image/png;base64,iVBORw0KG...
which is transformed to
background-image:url("/css/data:image/png;base64,iVBOR...
which, as you guess, is not valid.
Can you help me with this?
Thanks
As Facades are running with a singleton, if we set onlyUrl
or withFullUrl
all subsequent calls to Minify would preserve the value of these two flag.
I think both should be resetted to false just before returning from the render
function.
We're using the Plupload library by @moxiecode and have found an error when integrating it with Plupload 2.1.2 in it's minified version.
When we run:
{!! Minify::javascript('/assets/js/plupload/plupload-2.1.2/plupload.full.min.js')->withFullUrl() !!}
We get the following Errors:
ErrorException in Minifier.php line 476: Unclosed string at position: 67069
We know:
But when we put the .full.min.js file through Minify, the error is produced.
Here's the package link: https://github.com/moxiecode/plupload
Examples in README.md call Minify::javascript()
& stylesheet() statically, but these are defined as non-static functions in src/Minify.php. If these cannot be rewritten as static functions, then please provide examples of how to get & pass required $config & $environment args into new Devfactory\Minify\Minify($cfg, $env).stylesheet([])
for a correct syntax.
Not sure, if future versions of PHP will require such correctness, or other problems might ensue.
I've installed the plugin successfully.
Path to application http://localhost/app
If I include the css-files without slash at the beginning:
{!! Minify::stylesheet([
'assets/plugins/pace/pace-theme-flash.css'
]) !!}
I get the error message:
File '/Applications/XAMPP/xamppfiles/htdocs/app/publicassets/plugins/pace/pace-theme-flash.css' does not exist
If I add the slash I get no error message but the css-files are not loaded because the path is not correct:
http://localhost/assets/plugins/.....
Adding a base_url didn't help. What I am doing wrong?
Thank you!
FatalErrorException in efdbb806241fa94d03a450184eaa183f line 0:
Method Illuminate\View\View::__toString() must not throw an exception
This is more feature request then issue.
It would be nice if it can minify (save to file) inline javascript/css (passed as string) , ex:
Minify::javascript("<script>alert('x')</scirpt>")
Hi,
currently we have problems using this nice minify implementation on multiple servers. The deployment process sets different timestamps to public/assets files, so the filename hash generated by filename and mtime is different on balanced servers. If there is no sticky loadbalancer session, the laravel deployment try to open unknown hash-filenames on the other servers.
It would be great, if there is an config parameter to define the hash-building. Possibly only use filenames, or filenames with timestamps (currently), or other thinks.
What do you think about that?
Thanks,
Tobias
Hi,
I followed each steps in the documentation. The minified css are generated in the /css/builds folder and loaded and present in the final html source file.
But they are not loaded by the browser!
I deleted all caches but it is not working.
Any idea? Did I miss something?
Laravel 5.1
Thank you.
Font Awesome (or similar) icons, are broken after minification.
// add custom attributes
{!! Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'), array('bar' => 'baz')) !!}
Ive been looking through the sourcecode, but i coudn't quite figure out what the purpose is of "custom attributes", any help?
Hi,
Instead of minify.config.* values only minify.* should be used.
I'm getting errors that config values are not found.
protected function registerServices() {
$this->app->bindShared('minify', function ($app) {
return new Minify(
array(
'css_build_path' => config('minify.css_build_path'),
'css_url_path' => config('minify.css_url_path'),
'js_build_path' => config('minify.js_build_path'),
'js_url_path' => config('minify.js_url_path'),
'ignore_environments' => config('minify.ignore_environments'),
'base_url' => config('minify.base_url'),
'reverse_sort' => config('minify.reverse_sort'),
'disable_mtime' => config('minify.disable_mtime'),
'hash_salt' => config('minify.hash_salt'),
),
$app->environment()
);
});
}
Please have a look, Andrei.
Is there anyway to combine/compile a css array into one css file?
Sorry my systm have a error
On PHP 8 it causes timeout when trying to minify JS files.
Hi,
Maybe can you explain a bit how it works ?
I think it uses caching and looks at the last modification time of each css/js file to build a new minified version of each file, is that right ?
And it uses the laravel cache system ?
Thank you !
Allan
When minify is being used, and angular-material.js is getting minified.
The line 21481 of angular-material.js ( v1.0.4)
var urlRegex = /[-a-zA-Z0-9@:%+.~#?&//=]{2,256}.[a-z]{2,4}\b(/[-a-zA-Z0-9@:%+.~#?&//=]*)?/i;
Gets compressed as
var urlRegex = /[-a-zA-Z0-9@:%+.~#?&//=]{2,256}.[a-z]{2,4}\b(/[-a-zA-Z0-9@:%+.~#?&
It is skipping the second instance of '//='
When i'm not minifying my stylesheet, glyphicons works great. when I'm running the Minify::stylesheet, it breaks them...
Original CSS:
:root { --brendColor: #F13D30;
Minified result:
:root{--brendcolor:#F13D30;
"brendColor" has been replaced to "brendcolor"
as well as
background-color: var(--menulevel2active);
has been removed
Minify working good.
But i have trouble with include any file in css file, js file.
Have solution for this problem?
Route?
htaccess?
Hello. Is it planned minify for Laravel 8.2 ? Or can somehow adapt it for Laravel 8.2 ? Thank's.
Hi DevFactory, Im having this little problem, hope one of you can help me, Im working with the new bootstrap4 and other css files, some are local, most are in S3, but Im getting this (') in the middle, before html... what can this be? I know the business is busy, but maybe you're seen this problem before, thanks (Im on L5.4)
@media print {
.hidden-print {
display: none !important;
}
}
' html, body { height.......
Hi, thanks for the package, is been great using it, I was wondering if its possible to:
Specify the destination of the (css,js) file to example a S3 bucket? this would be great and save a lot of time
Config that the name is always the same, so every time we change or add a css file it doesn't output a new css file, instead it replaces the same and maintains only one
Hope you consider this, I prefer to use this instead of Elixir
I am try to add in php view not in php blade but its showing only <style></style> tag not the actual tag with url. Below is my code.
Controller
$css["css"] = array(url("/") . '/assets/css/web/register.css');
Php View
<?php if (isset($css)) { foreach ($css as $style) { echo \Minify::stylesheet($style); }} ?>
I'm using this library and it's useful for most aspects. I separated public assets for both desktop and mobile. Example folder structure:
So I need multiple config options for css_build_path, css_url_path, js_build_path and js_url_path. Now I'm using like this but it's not suitable for my situation:
'css_build_path' => '/webv1/css/builds/'
'css_url_path' => '/webv1/css/builds/''js_build_path' => '/webv1/js/builds/'
'js_url_path' => '/webv1/js/builds/'
Is there a logical way to achieve this?
Hi
I'm sure it's my fault but I can't seem to figure it out.
Added in composer.json:
"require": {
"laravel/framework": "5.0.*",
"devfactory/minify": "1.0.*"
},
Run composer update and got : "Installing devfactory/minify (1.0.7)"
Added in config/app.php:
'Devfactory\Minify\MinifyServiceProvider',
But getting: Class 'Devfactory\Minify\MinifyServiceProvider' not found
minify/src/Providers/StyleSheet.php
Line 57 in 4ed3809
It seems some code is missing before the strpos, it will always trigger the exception.
minify/src/Providers/StyleSheet.php
Line 60 in 4ed3809
Futhermore, the FileNotExistException use statement is missing in the header.
minify/src/Providers/StyleSheet.php
Line 61 in 4ed3809
On my minified JS file I have wrong statement:
varπ=Math.PI,ε=1e-6,d3_radians=π/ 180,d3_degrees=180 /π;
Oryginal line:
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
Laravel 5.1
devfactory/minify 1.0.1
Hello,
Regarding js minify, your package minify process is make the js file into one line?
or its compress minify with changing the variables names etc. ?
The way that files are minified in a directory is a mystery to me. I think it prioritizes subdirectories first which is a problem.
If my directory structure is this:
[multiple javascript files for my site depending on libraries]
[jquery and modernizr]
[jquery plugins]
I have no way of specifying order. I need /vendor/lib/ first, /vendor/plugin/ second, and then /app/.
The only way to accomplish this is to add 3 different Minify
instances which will create 3 requests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.