Conditional require #90
Comments
You can use |
@josh I have tried that however it seems that it isn't parsed because it ends up three lines down the file. |
Similar issue here. js.erb are not filtered by erb... |
|
If I write the following in my gem manifest file with erb extension:
erb is evaluated, but unfortuently the code in my manifest file is concatenated to one javascript file, but require statement is nt processed... |
Thank You. Using require_asset worked. I didn't know you could call it directly or that it existed. |
Thanks @josh for the hint to |
This seems like a very logical thing to want to do. Is there any explanation of why it works this way round (and you need the require_asset workaround) or plans to "fix" it in a future version? |
Seems like require statements are processed before the erb processor, that's why it doesn't have any effect. Strangely the require statement is still removed from the file instead of being left as a comment. Thanks |
Also anything after the erb's |
require_asset is being added to the end of the list, instead of in the order of this file. eg:
and the order ended up being: angular, common, angular-mocks |
jquery-ui-rails changes the folder structure, and Sprockets doesn’t provide a way to conditionally load assets, so the only real solution is to force ~> 5.0 Closes #3247 Ref: sstephenson/sprockets#90
@coli 's right, any solution to add file conditionally in application.js? |
jquery-ui-rails changes the folder structure, and Sprockets doesn’t provide a way to conditionally load assets, so the only real solution is to force ~> 5.0 Closes activeadmin#3247 Ref: sstephenson/sprockets#90
@coli @tam-vo Did you ever find a solution to this? No matter where I place my ERB conditional it's always added at the end of my file. |
This fix is targeted at 4.x. Right now the cache is using absolute paths to generate cache keys, this doesn't work if you end up running `rake assets:precompile` in different directories. Say you've moved your project or are running on a different server with a different absolute path. Or say, on every build on Heroku ever. This was reported in rails#59 and sstephenson#90 This commit is a introduces UnloadedAsset class that is responsible for among other things generating consistent cache keys. Previously when running https://gist.github.com/schneems/85f592ba2773761dfcf3 the output would show that the second build took over 38 seconds to build. With this patch applied it takes around 3.38 seconds. Most of this commit is docs, as the current behavior and use of the cache is not really documented, and extremely difficult to follow in the code. All existing behavior is preserved, all tests pass, an extra test was added to ensure that a project built using a previously built directory will be fast.
…he-paths-4.x [close sstephenson#90] Use relative path for cache keys
Having the same issue as @alex88 - everything after an erb tags is ignored and just plain text in the compiled .js file. Any solutions for that? |
I am working on a rails plugin and it has support for different javascript frameworks. With the new asset pipeline however, I can't select the correct file to use. I would like to be able to determine the framework available and load appropriate javascript.
The text was updated successfully, but these errors were encountered: