kriswallsmith / assetic

Asset Management for PHP
MIT License
3.75k stars 555 forks source link

Dumped filename is different from one on the web page #627

Open eatnut opened 10 years ago

eatnut commented 10 years ago

On my webpage, the path is like this href="css/0c3879e_reset_1.css", however, in my css folder, I found my dumped file named 0c3879e.css, have anyone had this problem before?

  1. The framework I use is built from Symfony component, not Symfony framework.
  2. I follow the exactly the same steps as Twig section on the main page.
  3. LazyAssetManager( which I used to dump file) and AsseticExtension depend on the same AssetFactory object, and this AssetFactory object doesn't have CacheBustingWorker added.
  4. As AssetFactory object doesn't have CacheBustingWorker , I'm wondering where does "_reset_1" come from? Does Twig engine adds the suffix?

Thanks!

stof commented 10 years ago

it looks to me that you dumped the files in non-debug mode while running the web page in debug mode (and so without combining the multiple files together)

eatnut commented 10 years ago

Thanks for replying!

When I removed the debug=true option from <% stylesheets ... %> tag, my problem is resolved.

Now, I have the following understanding for "debug" option in twig tags:

  1. When a dumper dumps the asset from that tag in template, it overwrites the dumper's factory's debug mode, and let the dumpper ignores the "?filter" for that asset.
  2. It let the Twig-Assetic extension to generate a fake links for each asset leaves. These links are used as demonstrating purpose and always returns 404 error.

Also, I'm wondering what is the benefit to use "?filter" instead of "filter" in twig tag?

          ignore ?filter    apply ?filter                                      
          +------------+   +-------------+                                     
          |dumpper1    |   |dumpper2     |                                     
          |+----------+|   |+-----------+|                                     
          ||factory   ||   ||factory    ||                                     
          ||debug=true||   ||debug=false||                                     
          |+----------+|   |+-----------+|                                     
          +------------+   +-------------+  

Let the dumpper1 dumps faster? Does it has any other purposes?

Thanks for taking your time!

stof commented 10 years ago

the issue is that the dumper does not take the case of debug=true into account properly: in such case, it should also dump the non-combined files, given that this got forced on a given asset

stof commented 10 years ago

and ignoring some filters is not meant to be faster (well, not as the main goal), but to be easier to debug. the filters you will generally mark with ? are the minifiers (it is less important now that browsers support source maps though, but it was not the case when Assetic started, so disabling the minification was the only sane way to debug)

eatnut commented 10 years ago

Got it, thank you!

eatnut commented 10 years ago

Hi, sorry to bother you again, I have another question:

  1. My index URL is http://localhost/project/web/
  2. The Twig-Assetic extension generates an URL (for asset_url variable) for an asset: href="css/51aeb6c-66102f1.css",
  3. This works fine under this URL: http://localhost/project/web/foo,

    As css file is refered to: http://localhost/project/web/css/51aeb6c-66102f1.css,

  4. However, if the URL is like this: http://localhost/project/web/foo/bar,

    The css file is refered to: http://localhost/project/web/foo/bar/css/51aeb6c-66102f1.css

    The file is missing.

Does Assetic has an option to generate a static absolute path like

/project/web/css/51aeb6c-66102f1.css?

Thanks!

eatnut commented 10 years ago

I found a solution, just rewrite the compileAsset() method in AsseticNode class.