-
Notifications
You must be signed in to change notification settings - Fork 202
Assets being fetched without .js extension #65
Comments
I just ran into this same problem. |
Me too. Have you found a solution yet? |
Also have this issue. Note that I am using RequireJS 2.0.6 using this branch https://github.com/Appboy/requirejs-rails so that running r.js doesn't break jQuery. |
John, glad to see you back! Any ideas on why this may be happening? It works fine in developer mode but after running the precompile and going to production mode, it tries to fetch the main-(md5hash).js file WITHOUT the .js extensions and therefore fails. The only solution I have so far is manually copying main-(md5hash).js to main-(md5hash). Once this is solved I'll be ready for a production deploy :) Edit:I've been attempting to debug this issue and have found that if edit the rjs_manifest.yml file entry to specify the .js extension TWICE it will then be loaded properly. Therefore, it seems the .js is just being stripped inappropriately. More to follow.... Edit 2:Here are some more observations. Keep in mind I'm pretty new to rails to I'm still wrapping my head around some of the basics in the asset pipeline. IN DEV MODE: - IN PROD MODE: - Edit 3: Temporary WorkaroundI decided to just skip the
|
We were running into this issue as well. Nto sure what the best solution is but think it is based on logic in require.js:
Ideally somebody who understands require.js and requirejs-rails will be able to come up with a more robust solution, but hopefully this helps them track down the root cause. |
This is a bug but has a simple workaround. Change your requirejs_include tag from requirejs_include_tag("mymain") to requirejs_include_tag{"mymain").sub("/assets/mymain","mymain") If you are interested in why this is a bug and why workaround works, read on. In RequireJS 2.0.x the data-main is treated like any other module that requirejs loads. Also RequireJS uses the path specified in the data-main to set the baseUrl if one is not specified in the config. Now RailsRequireJS does all the work for us including setting the baseURL in config to "/asset". You can see that in the HTML page source in production. It would look something like this: <script>var require = {"baseUrl":"/assets","paths":{"mymain":"/assets/mymain-3f6154ab7d ..." But the rails-requirejs incorrectly emits the data-main with "/assets/" prepended to it <script data-main="/assets/mymain-3f6154ab7d...js" src="/assets/require-b4a3df ...js"> // wrong
// should be this
<script data-main="mymain-3f6154ab7d...js" src="/assets/require-b4a3df ...js"> // correct The data-main in require.js include should not have a leading path (as explained in updated requirejs documentation). Because RequireJS treats it as an asset and not a module, it does not append ".js" when fetching it and worse it will not try to resolve it. We just strip out the leading "/assets/" and it will work for dev and production with cache-busted names. |
@ptyagi16 is right but I needed to use this code: requirejs_include_tag{"mymain").gsub("/assets/mymain","mymain").html_safe |
I believe this should be fixed on |
Gave 0.9.1 a spin, problem still existed. Thanks! |
Hello, I can report the original issue (asset fetched without the My code looks like this:
This triggers the right
This is a problem because it misses the
Here's the workaround:
The workaround simply overrides the |
Upgraded to 0.9.1 and i can confirm, the problem still exists, though as @jpurcell001 pointed out, works on master. |
I ran into the same problem and can confirm it's gone in the current master. My temporary fix looked like this: https://github.com/jmaicher/requirejs-rails/commit/903b3d0da91cc7a64b151f7ff0618aa5aa40306c From what I know we're always referring to a module in the data-main attribute, right?
Or am I missing something? @jwhitley Great see you working again on this gem!! |
solved with: |
I just upgraded to Ruby 2.0 so my gemset had to be re-installed. I think my in-use version of require-rails changed from 0.9.0 to 0.9.1, causing this bug (the file is not automatically appended with .js when requested in production). Rolling back:
fixed this problem, and now my assets are retrieved from S3 (asset_sync) correctly. |
All, I think this problem is fixed, as the gem now detects whether assets are eligible for precompilation. |
Hi,
I'm seing some really weird behaviour after upgrading to RequireJS 2.0, where assets that is outputted as "http://podio.dev/piped_assets/files_main-60bf86d78bb6e7fe62ece58006df4614" in the configuration, is being fetched without the .js file extension
This seems to have changed in RequireJS 2.0, and I can see that you are stripping out .js in file extension in the updated version of this gem (453089f).
Anyone else having these problems?
The text was updated successfully, but these errors were encountered: