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

Allow filters to provide paths for "depends" #240

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

glorpen
Copy link
Contributor

@glorpen glorpen commented May 12, 2013

aka automatic dependency detection.. by filters.
Not sure if it is the best way to bite it but looks easy and problem free (?).

Problem is discussed in #186
In this implementation if filter at any given time knows about existence of other deps (eg. after compass sources compilation or before when manually parsing files) it should just set depends property.

@miracle2k
Copy link
Owner

Only having this work "after" a filter has run is not good enough; that would means it work sometimes, and then sometimes not (e.g. right after a dev server restart); it would be confusing.

There really needs to be a way for the filter to parse the dependencies at the time when they are needed, which is before the build. I'm thinking a filter could have a find_dependencies() method which would basically run the code of @tgecho. Since it's going to be much the same every time, the code could be in a base class, and filters like compass or sass would simply provide the regex.

I also have to say that I'm still unhappy with the fact that this is necessary in the first place. I'd be curious to find out who other asset compilers handle it.

@glorpen
Copy link
Contributor Author

glorpen commented May 14, 2013

In my case (i have custom filter for compass) after filter was run i can list files which were used - which can be: fonts, images, other scc’s. If there will be parser for getting dependencies it would have to read compass mixins too (cause you could write some foreach inside to include sprites/fonts/etc).

What if filter deps could be cached? When new file is created it will be compiled & cached in some way (i don’t really know how it works now) and so would deps, so after restart deps can be read from cache and later eventually updated. If it is possible i will give it a try and see how it turns out :)

Don't know if anything changed but in AsseticBundle for Symfony2 the fix was: when in dev - make compiler run every request ;)

@glorpen
Copy link
Contributor Author

glorpen commented May 17, 2013

I've added caching for filter deps + deps recalculation after bundle is compiled.

@miracle2k - when doing above i found issue with hash in python>=3.3 - since hash'ing is used for creating keys for cache files, in newer version hash() return value is randomized per process - so it will change every time process is restarted. I'll try to use some hashlib function so it'll be constant again.

@glorpen
Copy link
Contributor Author

glorpen commented Jun 5, 2013

i've found out that in Assetic problem is now resolved by adding public function getChildren(AssetFactory $factory, $content, $loadPath = null); interface method to filter. Seems like it is ran before compilation.

Arkadiusz Dzięgiel and others added 4 commits August 1, 2014 13:06
@glorpen
Copy link
Contributor Author

glorpen commented Aug 1, 2014

I've updated pyscss filter to support functionality from this PR.

Currently deps are cached between app reloads so we have consistent state.

  • if master.scss changes, there will be compilation (and deps attribute update)
  • if _child.scss changes, it will trigger compilation too
  • if deps = None then there is no cache too (always?), so compilation will occur again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants