ceesvanegmond / minify Goto Github PK
View Code? Open in Web Editor NEWA PHP package for minifying your .css and .js.
License: MIT License
A PHP package for minifying your .css and .js.
License: MIT License
How can I set config for the paths in my app without modifying them directly?
$ php composer.phar require ceesvanegmond/minify:2.0.*
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ceesvanegmond/minify 2.0 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.1 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.2 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.3 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.4 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.5 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.6 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- ceesvanegmond/minify 2.0.7 requires natxet/cssmin 3.* -> satisfiable by natxet/cssmin[3.0.x-dev].
- Conclusion: don't install natxet/cssmin 3.0.x-dev
- Installation request for ceesvanegmond/minify 2.0.* -> satisfiable by ceesvanegmond/minify[2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7].
Installation failed, reverting ./composer.json to its original content.
Hi, Thanks for the package is great, Elixir is just big, I was wondering, can I install it in L5? Im getting a error adMethodCallException in ServiceProvider.php line 226:
Call to undefined method [package]?
Should I use version 2.0.* or 3.0.*?
Thanks you for you time
Including jquery-ui-1.10.4.min.js results in 'Invalid left-hand side expression in postfix operation',
including tinymce.min.js results in 'Unexpected token !',
including diff_match_patch.js results in 'Undefined is not a function'
And so on..use Laravel 4.2, JavaScript works error-free without minify.
I've added this line to providers:
'CeesVanEgmond\Minify\MinifyServiceProvider',
Published configs:
$ php artisan config:publish ceesvanegmond/minify
Use case in my view:
{{ Minify::stylesheetDir('/css/') }}
My composer.json:
{ "require": { "netson/l4gettext": "dev-master", "raveren/kint": "dev-master", "laravel/framework": "4.0.*", "barryvdh/laravel-ide-helper": "1.*", "leafo/lessphp": "0.4.*@dev", "aws/aws-sdk-php-laravel": "1.*", "ceesvanegmond/minify": "2.0.*" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/forms", "app/database/migrations", "app/database/seeds", "app/tests/TestCase.php", "app/library" ], "psr-0": { "Plupload": "app/library/Plupload/" } }, "scripts": { "pre-update-cmd": [ "php artisan clear-compiled" ], "post-install-cmd": [ "php artisan optimize" ], "post-update-cmd": [ "php artisan optimize" ] }, "config": { "preferred-install": "dist" }, "minimum-stability": "stable" }
Minifier should detect if a file is already minified and just include it without minifying it a second time.
Processing an already minified js file sometimes leads to a:
ErrorException in Minifier.php line 476: Unclosed string at position
This is not really an issue with the minify module itself, but with JSshrink and how it's beeing used. The error is thrown in vendor/tedivm/jshrink/src/JShrink/Minifier.php around line 471:
// New lines in strings without line delimiters are bad- actual
// new lines will be represented by the string \n and not the actual
// character, so those will be treated just fine using the switch
// block below.
case "\n":
throw new \RuntimeException('Unclosed string at position: ' . $startpos );
break;
I get an Exception when trying to use this package.
File:
public/html/vendor/ceesvanegmond/minify/src/CeesVanEgmond/Minify/Minify.php
Error:
$filetime = 0;
foreach ($this->files as $file) {
$absolutefile = $this->path . $file;
if (!\File::exists($absolutefile)) {
throw new \Exception;
}
Could you help me to sort out what causes this issue, please?
Thanks.
Hi,
Just wanted to use the bundle in a new project and noticed that an update was released which is good, but the paths isn't for the minifyed files are wrong in case of a subdirectory.
My laravel is located inside a directory on my host (example.com/example/laravel) and the linked files has a path of example.com/path_to_the_files not example.com/example/laravel/path_to_the_files.
Checked the code but theres no option to set this, like in the old versions.
Any suggestion?
{{ Minify::javascript(array(
'/js/partials/main.js',
))
. Minify::stylesheet(array(
'/assets/bootstrap/css/bootstrap.css',
'/assets/jquery-ui/css/smoothness/jquery-ui-1.10.4.custom.min.css',
))
}}
<link href="/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/assets/jquery-ui/css/smoothness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">
<link href="/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/assets/jquery-ui/css/smoothness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">
{{ Minify::javascript(array(
'/js/partials/main.js',
))
}}
{{ Minify::stylesheet(array(
'/assets/bootstrap/css/bootstrap.css',
'/assets/jquery-ui/css/smoothness/jquery-ui-1.10.4.custom.min.css',
))
}}
<script src="/js/partials/main.js"></script>
<link href="/assets/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/assets/jquery-ui/css/smoothness/jquery-ui-1.10.4.custom.min.css" rel="stylesheet">
in css
background: url(../img/pattern/boxed-pattern1.gif);
will generate:
background: url(../img/pattern/boxed-pattern1.gif);
will compress and saves compressed css inside folder, but path to the images was not corrected.
Here is the config:
'css_build_path' => '/css/builds/',
I think that generated css paths to the static images must be generated as:
background: url(../../img/pattern/boxed-pattern1.gif);
Sir
Thanks for this good package for laravel. I have some issue with this package. I put public folder and put on the root, so in normal case i use
{{HTML::style('public/css/style.css)}} it work well , but when i use this package i gave
{{Minify::stylesheet('/css/v-front-common.css')}}
Output website become
link href="css/builds/850a53aa7231cd72d94674fb352063081423895179.css" rel="stylesheet"
So style is not loading on the website, actual root
http:://localhost/videoreels/public/css/builds/<--stylesheet name-->
So is there any way to fix this one
When i gibe minift::stylesheet('/public/css/main.css') and ('public/css/main.css') it show error that
E:\MyWork\PHPWork\XAMP\htdocs\videoreels\publicpublic/css/v-front-common.css' does not exist
Hi,
composer :
"ceesvanegmond/minify": "2.0.*",
On :
Laravel 4.2
I got an error when i compress my javascript.
In my js code i got :
/(NaN| {2}|^$)/.test(a)
After compressed :
/(NaN|{2}|^$)/.test(a)
Obviously, an error occured ! How can i edit the javascript compression class to correct my situation ?
Thx a lot !
Would be good to gzip files on-disk instead of making the webserver do it every time it serves a file.
I get this when trying to Minify some libraries.
I have this config:
'css_build_path' => '/storage/cache/css/',
'js_build_path' => '/storage/cache/js/',
'base_url' => '/app/www/public/'
And this load:
<?= Minify::stylesheet([
'/bootstrap/css/bootstrap.min.css',
'/font-awesome/css/font-awesome.min.css',
'/fancybox/jquery.fancybox.css',
'/css/style.css',
'/css/custom.css'
])->withFullUrl(); ?>
The problem is that all background-image paths to load fonts are not changed, I think that it must be updated using base_url
param.
Before:
background-image:url(../images/logo-white.svg)
After:
background-image:url(/app/www/public/images/logo-white.svg)
There are some parameter to do it?
Regards,
Lito.
When I just checked out the web IDE Codio to work on a laravel app, I noticed that my assets weren’t loaded. The reason is that using Codio’s default setup my app is located at http://xy.codio.io:3000/public/
, and therefore my (CSS) assets are located at http://xy.codio.io:3000/public/assets/build/css/lots-of-numbers-and-letters.css
. However the link generated by minify is http://xy.codio.io:3000/assets/build/css/lots-of-numbers-and-letters.css
, i.e. minify doesn’t notice the path of the app. I think this should be fixed. Laravel’s asset()
helper function may be of help.
Hi,
Used your packacge and everything works like a charm but I end with a report from Firebug indicating that the minification is not done correctly. I minified the following js-files:
{{ javascript(array(
'jquery.min.js',
'jquery-ui.min.js',
'bootstrap.min.js'
))
}}
In Firebug that results in the following error:
Any idea?
Edwin
I got an exception when using this library.
Had to change the config calls from using :: to . in helper.php
That is:
From: $path = Config::get('minify::css_path', '/css/');
To: $path = Config::get('minify.css_path', '/css/');
I keep getting this error after upgrading to version 2.0
I also needed to provide credentials for github, I think this issue is related.
Failed to download ceesvanegmond/minify from dist: The "https://api.github.com/repos/ceesvanegmond/laravel4-minify/zipball/4d7ef9c1d1d5e0e848a9ee777f953f2b82d8d13a" file could not be downloaded (HTTP/1.1 404 Not Found)
Now trying to download from source
I am getting this error:
Class 'Minify' not found
Weird thing is that it is installed.
In app.php I have added:
'CeesVanEgmond\Minify\MinifyServiceProvider',
The files are all in the vendor folder...
My code in Blade:
{{ Minify::stylesheet('assets/css/style.css') }}
They say the error is on this line:
<?php echo Minify::stylesheet('assets/css/style.css'); ?>
Is this a new bug in Larevel 4? A problem with composer? It does not make any sense.
I also already did artisan dump-autoload.
I have Laravel 4.
PHP 5.5.10 (cli) (built: Mar 7 2014 08:41:26) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Using MAMP server.
In app.php I just added:
'Minify' => 'CeesVanEgmond\Minify\Facades\Minify',
But now I am getting this error:
Call to undefined method CeesVanEgmond\Minify\Facades\Minify::stylesheet()
I'm using minify with laravel in 2 servers, my own local machine where it works ok with a virtual host, and a server with an URL like:
http://111.222.333.444/somefolder/
On this server, minify builds something like
that is not correct because the route is /somefolder/assets....
even when I put 'base_url' configuration.
Something is wrong or am I doing something wrong?
Hello !
The possibility to delete old files will be keep the server more "clean" :)
Hi,
When I use the ignore_environments option, the minified files are still generated. The package just returns the path to the real files (not the minified ones).
I think it would be better when you're on a environment that needs to be ignored, the files are not minified. This is because whenever I change anything in the CSS or Javascript the minified files are re-generated and takes a lot of time.
Why did you abandon the package ?
If you need some help to maintain the package I will gladly take it over.
Hi,
CSS i want to minify has got some imports inside. The imported stylesheets are not beeing included.
Add to config file a var to debug mode and add 2 interesting lines to Minify::javascript and Minify::stylesheet to check if is a debugger environment and return the resource without process.
Specifically, my print style-sheets are no longer targeted to media="print" and I have no way to fix this without dropping use of this code. :(
I am using this plugin with laravel.
I have used the following code to minify my css.
{{ Minify::stylesheet('/Style/style.css') }}
But when I look at the output, I get this result: http://kljwaregem.be/Style/builds/38d1a869ca83e650d35d1ef7e069744e1411810998.css
Did I forget to add anything?
I have installed the package as you provided, but when i add {{ Minify::stylesheet('/css/main.css') }} in my header.blade.php below error occured, please clarify.
File 'E:\xampp\htdocs\topcutie/css/main.css' does not exist (View: E:\xampp\htdocs\topcutie\app\views\layouts\master.blade.php)
when adding this to providers
CeesVanEgmond\Minify\MinifyServiceProvider::class,
i get this error
BadMethodCallException in ServiceProvider.php line 234:
Call to undefined method [package]
my url : http://localhost/page1/pg/public
i used withFullUrl this call getBaseUrl an this return http:localhost
i replace
return sprintf("%s://%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['HTTP_HOST']
);
for
return \Request::getBaseUrl() // laravel
After following your instructions and then doing:
php artisan config:publish ceesvanegmond/minify
I'm getting the error:
PHP Fatal error: Class 'CeesVanEgmond\Minify\MinifyServiceProvider' not found in /var/www/laravel/bootstrap/compiled.php on line 4485
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'CeesVanEgmond\Minify\MinifyServiceProvider' not found","file":"/var/www/laravel/bootstrap/compiled.php","line":4485}}
What do I have to do to solve this issue?
Whenever I enable the plugin, the glyph icons in Bootstrap display incorrectly as empty boxes. Like the character encoding is changed. Is there a fix?
I just found that the icon fonts are created with the content css attribute, like:
content: "\e001";
Problem 1 - Installation request for ceesvanegmond/minify dev-master -> satisfiable by ceesvanegmond/minify[dev-master]. - ceesvanegmond/minify dev-master requires natxet/cssmin dev-master -> no matching package found.
Once you minify css and js all the relative urls go to on one file. And many resources e.g. images get linked wrong from your css or js. How do you deal with relative urls for resources? Or u have to edit all urls used in css and js files to be absolute? I have had to manually do that.
ceesvanegmond/minify dev-master requires natxet/cssmin dev-master -> no matching package found.
Please change natxet/CssMin in composer.json to use all lowercase to satisfy composer
Hi
I add this line to my blade file :
{{ Minify::stylesheet('/css/stylesheets/foundation.min.css') }} instead of {{HTML::style('/css/stylesheets/foundation.min.css')}},and it created a css file in builds folder under public/css, but when I run my page the requested url is localhost/css/builds/somename.css and of course it causes 404 not found error.
what is my fault??
Thank's a lot.
I've installed the library and when I want to use it in Laravel I got the error:
Call to a member function withFullUrl() on a non-object
If I remove the withFullUrl() method I got a link but is wrong pointed to my /public Laravel's path.
Who is wrong, the documentation or me?
Regards
...break the minified version when prepended to another file.
I've had this issue with qtip.min.js:
/* qTip2 v2.2.1 | Plugins: tips viewport imagemap svg modal ie6 | Styles: core basic css3 | qtip2.com | Licensed MIT | Sat Sep 06 2014 18:25:06 */
!function(a,b,c){/* Their code here... */}(window,document);
//# sourceMappingURL=//cdn.jsdelivr.net/qtip2/2.2.1//var/www/qtip2/build/tmp/tmp-656464emu9s/jquery.qtip.min.map
They're missing a trailing line break (which is ok), but when you combine it to other files and minify, the output is broken – the first line of code from the next file is missing. I think we should simply "sanitize" input files by adding a trailing line break if missing. Any objection?
Hi, i'm interested in use path in app folder, not be stuck on public, so i tried to extend your Minify class and change the methods (javascript / stylesheet, also dir methods) but many methods and variables are private.
i suggest to use realpath so we can add two dots with slash to access the app folder...
by the way, my structure is like app/admin/css, app/admin/js etc and the builds should continue in public path...
How can i change the naming convention to something simpler like just "style.min.css", because from the look of it, if you have quite a number of files to minify, the eventual name can get really long, really fast
In config create a flag for Production so we can turn on/off minfy.
Hi in start.php if I return 'local' environment it ignores the minification, if I return 'production' produces minification which is fine.
What doesn't work is if I am in 'local' environment and decide I want to see what the minification looks like and remove 'local' from the ignore_environments, it still produces the raw files, doesn't take the settings into account.
Same visa versa, if I am in 'production' and decide I want to see what the raw files are, and specify in the config to ignore 'production' it still produces the minified version.
Basically nothing I put in the ignore_environments works.
Only way I can make it work and switch between minified and not minified is by specifying 'local' or 'production' in the start.php. Config file does nothing?
Hi, right now returned minified asset is relative path, so how to return with full url?
thanks
All my js/css are in public folder and i am using {{ Minify::javascript('/js/custom/reminder.js')}} which successfully creating minified file in builds folder but its not included in page. From console i can see url generated by Minify isn't correct. Its coming like below url with 403 error code. I am using laravel 4.1. How i can fix it.
Hi
It would be great if a method exists that only returns the URL of the minified file instead of a pre filled HTML element.
This way CDN fallbacks may be defined while still pointing to a minified local version, e.g:
{{ HTML::script('//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js') }}
<script>!window.jQuery && document.write(unescape('%3Cscript src="URL HERE"%3E%3C/script%3E'))</script>
(I know jQuery can be downloaded already minified but this is just an example)
¡Great! ¡Works fine!
But I have several questions:
¿How can I customize final URL? I woud like to add this string "?v=32654" to the final of the URL.
The builds are created in every runtime? Can I created statically in production?
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.