Oskar
Oskar

Reputation: 139

Assetic route gives 404 for javascript

Just following the cookbook for Symfony2 2.3 and trying to use Assetic for assets management.

I'm here: How To Use Assetic for Asset Management, using a fresh 'install' of Symfony2 2.3.3 with vendors.

So I generated a skeleton with php app/console generate:bundle and it loads as it should.

I then created two new folders under Resources, public and js and just created a my.js with a console.log() in it.

Now when I reload the page I just get
[18:53:23.126] GET app_dev.php/js/b36694f_part_1_myjs_1.js [HTTP/1.1 404 Not Found 2ms]

And if I do php app/console route:debug it's created as I would expect:

Name                      Method Scheme Host Path
_assetic_b36694f          ANY    ANY    ANY  /js/b36694f.js
_assetic_b36694f_0        ANY    ANY    ANY  /js/b36694f_part_1_myjs_1.js

It looked to me like this was some magic that would just work, and that dumping the assets comes later when I want to run it in prod. Iv'e seen some posts about running with --watch but that should only be necessary when running with use_controller: false ?

Any tips, pointers or anything..

Upvotes: 0

Views: 965

Answers (1)

Oskar
Oskar

Reputation: 139

Found it.. It was in the Nginx-config:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  expires max;
  log_not_found off;
}

I commented this out and, lo and behold, did it spring to life.

I guess that's what you get for copying configs from another project.

Thank you SO!

Upvotes: 1

Related Questions