-
Notifications
You must be signed in to change notification settings - Fork 580
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
Assetic is not aware of asset dependencies #79
Comments
I've begun work on this in the mtime-aware branch. |
is it already testable? |
not yet. On Jun 24, 2011, at 9:01 AM, matteosister
|
This is a symptom of a larger issue of asset dependencies that will have to be addressed in a later version.
What's the state of this issue? Seems like it was postponed, were there any difficulties? |
This is not going to make it into 1.0 unfortunately, but it will probably be the only enhancement in 1.1. |
Some open questions:
And probably more... |
See #96 also. |
do you think it's possible to use some native ruby implementation (link this) or plain php to parse line by line the sass/scss files? |
What's the status on this issue? Is it possible to disable caching completely (on development environments of course) until this is resolved? |
disable caching could be a good solution....but I don't think there is a "clean" way to do it... |
This is not always the case: when doing minor CSS tweaking you constantly have to save two files, where you want to be fast switching between editor and browser. I know that tweaking in an inspector is faster and sometimes better, but even then I still switch between editor and browser regularly. As for small projects: I'm currently working on a project where I keep the media query specific CSS in separate files, and import them at compile time in media queries, but also without media queries for IE<9. There are other use cases to think of where using imports is much more handy, even though the size is not that large. Edit: this is a separate discussion for a disable-cache flag, obviously. Let's focus on the main issue here. :) |
The workaround I've been using for the past weeks is "double watching" my files. I fire up the compass watch with a config.rb file to watch for scss file changes, and use assetic to watch on compass' compiled css files. This double watching for now is a bit annoying, but works well until assetic can support dependency watch. |
@pkruithof I'm using a single file just because of assetic...normally I use only external files, and in my main file I only import things @srosato So you are not using the CompassFilter..but some css filters (like yui compressor)? It's a shame because compass itself compress css files pretty well.... To me a solution could be: define a list of dependencies given a base file, and assetic should watch all the timestamps. |
Yeah I know it's a shame for now, yeah I'm using other filters like CssRewrite and YuiCompressor after compass compiled the css files, but not the CompassFilter for now since the asset dependency watching is a must for me. I wish I had a little more time as I would try to give a hand on this issue by contributing. |
I hope that this pr will bring some quick solution for all these problems... |
Also waiting for a solution... |
@ConneXNL, @srosato here is a solution... CompassElephantBundle |
+1 on needing a solution for Less |
@redemption quick solution waiting for this issue to be closed https://github.com/matteosister/LessElephantBundle if you try it please let me know if it works for you. |
also related to #190 |
@schmittjoh are there any plans to find a solution for all these problems? |
My plan for Minify is to have smart assets ("sources" in Minify) that know how to linearize and manage watching the dependency files for changes. Internally they would cache the list of dependencies so getLastModified() could simply get the max() of all the dependencies. getContent would re-linearize everything and cache the new list. This, of course, bypasses all the questions about how dependency files are treated: they're treated as a single asset, period. I'm not all that familiar with LESS yet, but maybe a similar LessLinearizerAsset could do the same thing for LESS: just process the imports and leave the processing for the filter. If LESS requires distinct files for vars I guess this wouldn't work. |
any updates on this one? its a real showstopper. |
Isn't there a way to disable the cache in dev environments ? |
@arcanis I don't think it's a solution, but only a workaround... |
Didn't say it was a solution. But until we found a solution, it would be great to at least have a workaround. And actually I think it could be a solution. In a dev environment, why using a cache ? |
@arcanis because something has to be cached I think. Or you end up waiting for 25 secs for every request. Anyway, don't know if there is a way, and never tried it. |
An example of how to get the supposed fixes working this less would be appreciated. (ie. config settings and filter settings) I've been tinkering for days and this is still an issue. |
I still having problems to use sass in my project; the css files do not recompile with every request in development environment (in this case. scss files). Is this issue solved for SASS? Here is my config: config.yml
Includes
main.scss
I am using Assetic 1.1 under Symfony 2.5.* |
the issue is resolved for the SassFilter, not for the CompassFilter which is the one you are using. See #640 for the implementation for CompassFilter |
@stof the issue doesn't seem to be resolved yet for SASS/SCSS. |
@stof We are still having this issue for SCSS files. However, if we disable the asset controller, and watch the files, it does detect changes from @imports.
|
@stof Not working for me. Details below. What should I do now? /app/config/parameters.yml
/app/config/config.yml
/src/bundles/MyBundle/Resources/views/Pages/Index/index.html.twig
/src/bundles/MyBundle/Resources/sass/homepage.scss
/src/bundles/MyBundle/Resources/sass/_common.scss
/composer.json
|
Can confirm that using I also tried using latest dev-master of Assetic, but nothing changed. |
@stof @kriswallsmith Could this issue be reopened please? |
Experiencing exactly the same issue as @liviucmg here |
Going off on a tangent here. I'm guessing many people will be using Gulp or Grunt. Adding the ability for assetic:dump to target a single asset will give a lot of people the ability to use those tools to watch for changes while still having assetic work its magic on the individual assets themselves. E.g. use Gulp to watch: use assetic (from within Gulp) to dump: It will also eliminate the need to re-invent the wheel inside assetic/symfony when there are great tools already available. (Gulp, Grunt) |
Same here. Watching imported assets does not work. Also I'm not interested in installing Gulp or whatever for just watching the SASS files. I bet there are also others thinking the same. So no need to re-invent the wheel but fixing the issue would be great :-) |
@moezkorkmaz the issue is that Assetic would need to re-invent the wheel by resolving sass imports. Something that is done by libsass if you use gulp. From the gulp-sass page (https://www.npmjs.com/package/gulp-sass): gulp-sass is a very light-weight wrapper around node-sass, which in turn is a Node binding for libsass, which in turn is a port of Sass. There are a couple of libsass wrappers for php: https://github.com/sass/libsass/blob/master/docs/implementations.md#php Perhaps these would be a starting point. But it would involve adding an extra php extension to your environment. |
I would suggest to get rid of assetic and php to manage assets. In my opinion it's not worth it. Better go with javascript and a build tool like webpack or gulp. |
@henrypenny As far as I know Assetic knows about asset dependencies. The sass filter parses the file and resolves all imports in it. See |
Forget about Assetic, come up with a build process using front end tools like Gulp and get things like CSS livereload for free. Plus a performance boost on development as Assetic makes Symfony really slow, at least five years ago when I last checked. |
@mpdude Is this your opinion as a maintainer or as an user? |
@MatthiasKuehneEllerhold my recommendation as one of the Assetic maintainers is indeed to switch to a stack built directly using frontend tools if it can fit your workflow. There are 2 different ways to use Assetic:
In the second case, my recommendation is clear: stop using Assetic and switch to Gulp or equivalent. Assetic was written at a time available tools were mostly Java and Ruby ones, with no easy way to build a stack combining them automatically. But the ecosystem has evolved a lot since 2011. |
@MatthiasKuehneEllerhold I dug deeper into Assetic a few years ago, also trying to solve this particular issue. I had to learn that it is not worth the hassle and so I can only endorse what @stof says. As I was mostly using SASS and cssrewrite, the transition over to Gulp was pretty straightforward. I should have a how-to presentation lying somewhere around (in German), email me when you're interested. |
Now thats a grim outlook. We just started a new project and integrated assetic in it. I was worried that it might be abandoned due to 100+ open PRs and no commit for half a year but all the other options weren't as good. I really liked the ZF integration... |
@MatthiasKuehneEllerhold lots of opened PR are about adding new filters dealing with more Node.js tools. And as I had few time to dedicate to Assetic these past months (and @kriswallsmith even less than me), adding more filters we don't use and we would have to maintain is not something we rushed about, especially given that we know that they would become outdated a few weeks later when the tool adds new options. |
@MatthiasKuehneEllerhold @stof I had some success writing my own assetic filter some time ago. https://github.com/henrypenny/hmp-assetic-bundle Its basically a copy and paste of the cssrewrite filter. But it handles From memory it was working reasonably well with my use case. I could set up watches in grunt or gulp and get assetic to dump them. But that approach dumps everything at once - css, images, js - which is far too slow. I wanted to be able to target a single sass file like so: `app/console assetic:dump '@AppBundle/css/style.scss`` But I didn't get that far. Targeting single files with assetic:dump would allow assetic to remain lightweight and let other frontend tools do the heavily lifting. But we could still have the benefits that assetic offers with regard to managing frontend resources from multiple bundles etc. |
@stof an alternative I didn't try: https://github.com/romanschejbal/gassetic |
Well, I don't see the benefit of gassetic compared to using gulp directly. Replacing the Gulp config file (which can contain code) with a YAML used to generate it seems to me like it may suffer from the same limitations about tool support (but I may be wrong as I just looked at it quickly). |
@stof how hard would it be to modify assetic:dump to target a single asset - or better still a list of assets? |
Well, there is some challenge here, because asset names in the manager are truncated sha1 hashes by default (and I doubt many people are naming their assets explicitly in Twig, as I'm not even sure we ever documented how to do it). So you would have a hard time passing the argument. |
IMO ideally one would reference assets like this:
How does assetic resolve note: I had some success referencing sass assets like this in an experimental copy of cssrewrite I did a while back. Do you think this conversation deserves its own issue? |
@henrypenny the issue is that this is not the asset being added in the manager (and so dumped). What you need is to reference the |
and yes, please move this to a dedicated issue |
As discussed here there is a problem with the new implementation of the compass binary.
The problem is that, the cache system, checks the timestamp of the sass file without involving the filter.
So if you have a main file which imports other "subfiles" (a typical situation working with compass) and you never edit this main file you never get a recompile.
The process of check the timestamp of an assetic file should in some way involve the filter to get a complete list of files to check and eventually trigger the recompile by checking all the timestamps.
This issue is related to compass, but I think it should also appear in Sass and ScssFilter and also on any filter that deal with an asset with a tree of subassets
The text was updated successfully, but these errors were encountered: