Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for pre-processing langs #23

Closed
niallobrien opened this issue Aug 22, 2013 · 11 comments
Closed

Instructions for pre-processing langs #23

niallobrien opened this issue Aug 22, 2013 · 11 comments
Labels

Comments

@niallobrien
Copy link

Hi, I'm using Less, and there doesn't seem to be any instructions on how exactly I can automatically compile a less file and have it served via the asset pipeline. I'd imagine I need to use Assetic or something to help with the compilation process. Please advise, thanks!

@livkiss
Copy link
Contributor

livkiss commented Aug 22, 2013

Your less files get compiled to css automatically, it is all about how to access them.
You need an manifest file that states which stylesheet files should be included into your compiled .css.

If you install a fresh copy of asset-pipeline (following the steps in README), there will be application.css which includes every file in the same directory (require_tree .).

If you have the following file structure:

your_laravel_project/
    app/
        assets/
            stylesheets/
                application.css
                some.css.less

http://<your laravel project>/assets/application.css will include the compiled version of some.css.less

But you are not limited to the default application.css, you can organize your manifest .css files anyway you want.

If your want to group all your stylesheets for e.g. your users section of your app, you can do the following:

your_laravel_project/
    app/
        assets/
            stylesheets/
                users/
                    user1.css.less
                    user2.css.less
                application.css
                users.css

and then in your users.css:

/**
 *= require_tree users/
 */

http://<your laravel project>/assets/users.css will include the compiled version of all files in the users/ directory

You can generate a link tag for your manifest files via <?= stylesheet_link_tag('users') ?> or @stylesheets('users') if you are using Blade.

Hope this helps!

@niallobrien
Copy link
Author

Okay, I placed a simple test.less file in the same directory (app/assets/) as application.css and when browsing to localhost:8000/assets/application.css, the css file remains blank. Any suggestions?

@livkiss
Copy link
Contributor

livkiss commented Aug 22, 2013

run php artisan config:publish codesleeve/asset-pipeline to get app/config/packages/codesleeve/asset-pipeline/config.php.

Look at the filters array. Here you can see what file extension your files should have to get compiled. Default for Less is .css.less, so I would suggest you rename your test file into test.css.less

@kdocki
Copy link
Contributor

kdocki commented Aug 22, 2013

@niallobrien did the stuff @felixkiss suggested fix your issue?

@felixkiss, I think I will put some of what you said here into the usage section of the README.md just for future usage...

@niallobrien
Copy link
Author

@kdocki No, even after publishing the config, checking the defaults and renaming my less file, nothing is compiled. application.css remains empty.

@livkiss
Copy link
Contributor

livkiss commented Aug 22, 2013

@niallobrien One more thing I often need to do: php artisan assets:clean to delete the cache

@kdocki The caching thing with production environment behaves a little weird. Still couldn't fully grasp how it should work. And I have some projects with custom named environments. Maybe an option in the config which environments should get "production mode" and which ones should regenerate on every request (dev mode)?

@niallobrien
Copy link
Author

@felixkiss Yup, that was it, thanks! So it's definitely a cache issue. Regenerate on every request for dev mode would be ideal.

@kdocki
Copy link
Contributor

kdocki commented Aug 24, 2013

@niallobrien if you set your environment to be local ( check out https://github.com/CodeSleeve/asset-pipeline#installation ) that will take care of caching.

@felixkiss all environments are all treated like local envs (except production). Here is where that happens for javascripts. Do you have any ideas for this config thing? One thing I wanted to be weary of is file reads on production. So when users go to /assets/application.css I didn't want the server to have to process the package config.php every time that file is hit.

Is the caching thing not working as expected? You should really only get a cache on the 'production' environment... is that not what is happening?

@gabrielalack
Copy link

Hey guys, I'm having a similar problem.

I'm coming from a Codeigniter background, I'm relatively new to Laravel, and I've never used Rails, so forgive me but I'm having a hard time following your documentation.

I'm pretty sure i have everything configured correctly.

The only thing I'm doing differently is loading the paths dynamically because I'm using a dynamic theme setup. So in my config file the paths are empty, but I'm using the event handler to give it the path of whatever theme template is in use using $paths->add(...)

Images get sent through fine, as do any css and js that I put in folders added as 'other'

However, I'm not getting anything if I try to fetch css or js from a 'javascripts' or 'stylesheets' folder. Just blank, even if I try to reference the files directly.

I've tried clearing the cache.

Can you please explain the difference in how to handle these files between development and production mode? This is the most confusing part.

@niallobrien
Copy link
Author

@kdocki Yeah, I'm using php's server via artisan serve, so I set my machine name to "localhost" and it's working fine, thanks.

@kdocki
Copy link
Contributor

kdocki commented Aug 27, 2013

@gabrielalack Yeah, I will make a section under FAQ about using in development and production. I might make a video specifically for that.

Also I just created two videos last night but it only applies to dev-testing branch at the moment ... I will be making a merge into dev-master pretty soon though

@kdocki kdocki closed this as completed Aug 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants