Open Marwelln opened 11 years ago
Hm, my guess is it's not building because the environment isn't production. This probably isn't ideal. If you look at the alias for CssMin
it uses whenEnvironmentIs('production', 'prod')
which means only when your application is running on that environment will it apply.
I might add a requirement like whenProductionBuild
or whenDevelopmentBuild
to only apply during a production or development build. Fix coming shortly.
I changed my environment between local
and production
, none are minimizing the files.
You'd need to remove the whenEnvironmentIs
requirement from the CssMin
filter alias.
Removing it did nothing. I deleted the previous builds and ran the command again, but it's still not minimized.
'CssMin' => array('CssMinFilter', function($filter) { $filter->whenClassExists('CssMin'); }),
This in the config.php
file.
PS. I'm on Windows 7.
How are you loading CssMin and JSMin? Have you seen: http://jasonlewis.me/code/basset/4.0/filters#windows-compatibility
I've pushed out a fix that may or may not solve your issue. The config file has been updated to include to changes.
There are now whenProductionBuild
and whenDevelopmentBuild
requirements available for filters. So the filter will only be applied to either of the builds. The config has been updated so that CssMin
and JsMin
are only applied when it's a production build.
Now, make sure you have the CssMin library downloaded and autoloaded with Laravel. If you want Composer to manage it all then add a repositories
key to your composer.json
like so:
"repositories": [
{
"type": "package",
"package": {
"name": "cssmin/cssmin",
"version": "3.0.1",
"dist": { "url": "http://cssmin.googlecode.com/files/cssmin-v3.0.1.php", "type": "file" },
"autoload": { "classmap": [ "cssmin-v3.0.1.php" ] }
}
}
],
Then in your requires
key:
"cssmin/cssmin": "3.0.*"
You should now be able to use the CssMin
filter.
He shouldn't have to modify his composer.json. CSSmin is a required repo in Assetic.
It's a dev dependency.
I am struggling with this too. I've added CssMin via composer as suggested by Jason, and also removed the requirement for a production build from my Basset config file, but this just won't work:
Basset::collection('bootstrap', function($collection)
{
$collection->add('assets/css/less/bootstrap-custom.less');
})->apply('Less')->andApply('CssMin');
I can see cssmin
in both node_modules
in my application root (I installed via node rpm) and also now in vendor/cssmin
.
I have verified by class_exists('CssMin')
that the CssMin class does exist.
Removing ->andApply('CssMin')
from the filter chain triggers a build. But adding it back in gives Stylesheets build was not required for collection.
when I run the artisan build command.
Any idea what's up?
(and thanks for Basset - I love it, with this minor glitch sorted it will be my asset publishing dream realised!)
Just a follow up...
Adding the --production
flag to the Artisan build command sorts this out in my case.
@raffjones if you look at the filter definition for CSSmin around line 234 in the config.php, you will see that whenProductionBuild()
returns true is when CSSmin is actually applied. Same goes for JSmin
The problem in my case is that the nested composer.json
of kriswallsmith/assetic
isn't executed when using composer install
from the root. Therefore no dependencies are loaded/installed and so nothing is compressed.
I have the same problem. I composer installed CSSmin and it does minification now but with a weird problem: the styles aren't applied even the css file is ok and firebug shows all the style declarations there, but not on any elements.
But the main problem here is that when CSSmin and JSmin are included in Assetic, they aren't loaded for some reason?
Can't you just add https://packagist.org/packages/natxet/CssMin instead (packagist clone of the google repo). Assetic doesn't just download all the filters, because it doesn't know that filters you are going to use..
@barryvdh I have mrclay/minify installed which seems to work with JS but not with CSS - weird? How does Basset know which libraries are there and how it chooses which to use?
@jasonlewis I'm also having a weird issue with debugging... When I have defined environment as 'local' and added that to Basset configs production environment array, neither minification nor combining of files are happening. Issue persists also if I have set 'production' key in $app->detectEnvironment array to 'projectname.local' (my working MAMP host) and dd($env) right after to verify set environment.
On the real production environment all is running ok except for the CSS minification not happening with mrclay/minify installed - do I need to config that somewhere?
Addition: Could mrclay/minify intervene with Assetic's required cssmin/cssmin? Though before I added mrclay/minify neither CSS nor JS minification was happening.
It uses mrclay for js, not for css. Depends in the filter. You can write your own filter if you want, like this https://github.com/barryvdh/assetic-filters/blob/master/src/CSSminFilter.php
Just as https://github.com/jasonlewis/basset/issues/65, using
->apply('CssMin')
is not working.In my config.php file I have this collections array: 'collections' => array( 'application' => function($collection) { $directory = $collection->directory('assets/css', function($collection) { $collection->requireDirectory(); });
Then I run this
artisan
command:php artisan basset:build application
It builds fine, but the problem is that the output is not minified.