efficiently / larasset

Larasset is a library for Laravel 4, 5.0, 5.1, 5.2 and 5.3 which manage assets in an easy way
http://laravel.io/forum/07-18-2014-package-larasset-asset-pipeline-the-ultimate-front-end-tool
MIT License
67 stars 5 forks source link

Production pre-compile generates an error #6

Closed tsiedsma closed 9 years ago

tsiedsma commented 9 years ago

I've been testing your package and have run into an issue in my local and development environments. Both systems produce the exact same error when trying to pre-compile assets for production use.

$ php artisan larasset:precompile --environment production

[InvalidArgumentException] There are no commands defined in the "larasset" namespace.

Running the same command without the environment option does a successful pre-compile but does not minify or compress anything.

laravel.log entry:

[2014-12-01 15:55:06] false.ERROR: exception 'InvalidArgumentException' with message 'There are no commands defined in the "larasset" namespace.' in /vagrant/vendor/symfony/console/Symfony/Component/Console/Application.php:516
Stack trace:
#0 /vagrant/vendor/symfony/console/Symfony/Component/Console/Application.php(550): Symfony\Component\Console\Application->findNamespace('larasset')
#1 /vagrant/vendor/symfony/console/Symfony/Component/Console/Application.php(190): Symfony\Component\Console\Application->find('larasset:precom...')
#2 /vagrant/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /vagrant/artisan(59): Symfony\Component\Console\Application->run()
#4 {main} [] []
tortuetorche commented 9 years ago

Hi,

Can you run this command in your terminal ?

php artisan env

It should not output production, can you check this ?

And you need to enable debug mode in your local or development environment. Create or edit the file app/config/local/app.php:

<?php

return [
    'debug' => true,
    // Others config options....
];

See also #5

tsiedsma commented 9 years ago

Current application environment: local

Debug is set to true in my app/config/local/app.php

tortuetorche commented 9 years ago

Can you try to create or edit this file app/config/app.php:

<?php

return [
    'debug' => true,
    // Others config options....
];
tortuetorche commented 9 years ago

The issue is here.

This code doesn't seem to work with local env:

$this->app['config']->get('app.debug')

I need to find a way to read the debug config option in other env than production...

tsiedsma commented 9 years ago

Thank you, setting debug true in production app.php did the trick.

I have another question. My local server is on vagrant and uses apache, when larasset generates links to assets, it uses localhost:3000, is there a way to have it use the real url and port like the rest of laravel? I'm not running the artisan server...

<link media="all" type="text/css" rel="stylesheet" href="http://localhost:3000/assets/application.css"&gt;

Should Be:

<link media="all" type="text/css" rel="stylesheet" href="http://localhost:8080/assets/application.css"&gt;

tortuetorche commented 9 years ago

If your application is in production mode and your assets are precompiled it should be OK.

tsiedsma commented 9 years ago

It's my local dev instance, it's in local mode. I need to be able to work on my local dev instance and have the links generate properly.

http://localhost:3000/assets/application.css is a 404, that port doesn't exist and is not forwarded through vagrant.

tortuetorche commented 9 years ago

You can set this env variable : ASSETS_ENV=local

tsiedsma commented 9 years ago

I can confirm that works, thank you for your prompt help!

tortuetorche commented 9 years ago

OK, I reopen this issue because of the local debug config option bug.

tortuetorche commented 9 years ago

The commit 8559325 fix this issue. So the --environment command line option is renamed to --assets-env. and larasset-environment command line option is renamed to --larasset-env. So don't forget to change your build script :smile: