sprockets

Precompiling a .scss manifest file using Rails 3.1's asset pipeline

混江龙づ霸主 提交于 2019-11-30 13:43:20
问题 The release version of Rails 3.1 is having some weird issues with precompiling a sass manifest file with the extension scss . The weird thing is that the default manifest file application.scss compiles fine and I see it under public/assets/ . However when I try to compile my custom manifest files, nothing is created. I have enabled the precompile option in the production config. config.assets.precompile += %w( user.scss admin.scss ) I am running the precompile rake task correctly as far a I

Rails 3.1 Sprockets require directives - is there a way to exclude particular files?

此生再无相见时 提交于 2019-11-30 11:44:29
问题 If I'm using //=require_tree . in application.css, is there a way to exclude particular files other than resorting to //=require_directory and tree organization? Perhaps something like //= require_tree ., {except: 'something'} 回答1: This is possible with Sprocket's new stub directive which is available in Sprockets v2.2.0 and up. However, Rails 3.2 will only ever use Sprockets v2.1.3 which does not have this feature. As of now, the current Edge Rails has the stub directive and it will

如何在另一个JavaScript文件中包含一个JavaScript文件?

百般思念 提交于 2019-11-30 11:40:20
JavaScript中是否有类似于CSS中 @import 的内容,可让您在另一个JavaScript文件中包含一个JavaScript文件? #1楼 而不是在运行时添加,而是使用脚本在上传之前进行串联。 我使用 链轮 (我不知道是否还有其他 链轮 )。 您将JavaScript代码构建在单独的文件中,并包含由Sprockets引擎处理的注释(包括)。 对于开发,您可以依次包含文件,然后在生产中将它们合并... 也可以看看: Sprockets简介:JavaScript依赖关系管理和串联 #2楼 如果有人在寻找更高级的东西,请尝试 RequireJS 。 您将获得更多好处,例如依赖管理,更好的并发性,并避免重复(也就是说,多次检索脚本)。 您可以在“模块”中编写JavaScript文件,然后在其他脚本中将它们作为依赖项引用。 或者,您可以将RequireJS用作简单的“获取此脚本”解决方案。 例: 将依赖项定义为模块: some-dependency.js define(['lib/dependency1', 'lib/dependency2'], function (d1, d2) { //Your actual script goes here. //The dependent scripts will be fetched if necessary. return

How to clear Sprockets cache?

我与影子孤独终老i 提交于 2019-11-30 10:53:04
When a Sprockets object compilation fails (due to a syntax error in CoffeeScript or SASS), it cannot recompile after the error is fixed because it says "file is already required." In order to get the Sprockets object to work, I have to destroy and re-create it. I was wondering if anyone knew if there was a way to tell the Sprocket object to internally reset itself as to not run into this issue. rake tmp:cache:clear deletes the temporary cache directory. In my case, the following command worked: rake tmp:clear It should be: Rails.application.assets.cache.clear but this method only in master

Rails 3.2.8 Application.js and Application.css are not working as expcted

Deadly 提交于 2019-11-30 08:53:19
When i try to include <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> The content of the files of the application.css is: /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's

Assets say “not precompiled” when they are precompiled

家住魔仙堡 提交于 2019-11-30 08:28:11
Ok so, I'm getting this error when I try to use the asset pipeline. I don't understand what's causing it. Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#show Showing .../app/views/photos/_photo_view.html.haml where line #2 raised: jquery.autocomplete isn't precompiled Extracted source (around line #2): 1: - content_for :scripts do 2: = javascript_include_tag 'jquery.autocomplete' However, this IS precompiled. I ran rake assets:precompile RAILS_ENV=production before starting the server, and in my public/assets directory I have the file: jquery

Sprockets encoding error on js file: invalid UTF-8 byte sequence

烈酒焚心 提交于 2019-11-30 08:27:16
A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8. The line in question is: * Copyright (c) 2010 - 2011 Johan Säll Larsson If I replace the ä character, the problem goes away, but I don't want to have to remember to edit this vendor file everytime I update it. How can I fix this? I found the solution via the comments on this Sprockets issue : I simply saved the file as utf-8, (TextMate has an option to do this when you chose 'Save As'), and the problem went away. The commenter @shedd also created a useful rake task to find assets which

Asset pipeline, compass font-face and eot?iefix call to the font

余生颓废 提交于 2019-11-30 07:35:52
I am trying to use a Compass font-face mixin, which contains the inclusion of *.eot?iefix My app/assets/fonts contains all the font types needed, including .eot. When I try to run assets:precompile the task fails saying something like: webfont.eot?iefix isn't precompiled Do you know the possible solution for this problem? It runs with no error in case I have config.assets.compile = true, but as I've understood it's better not to use it on production. You can do it with pure Scss too: @font-face { font-family: 'DroidSans'; src: url(font-path('DroidSans-webfont.eot')); src: url(font-path(

Disable Sprockets asset caching in development on Rails 4

回眸只為那壹抹淺笑 提交于 2019-11-30 07:25:45
Another question " Disable Sprockets asset caching in development " addresses how to disable Sprockets caching in Rails 3.2. How do you do the same thing on Rails 4? I am working on a gem that is deep in the asset pipeline and having to clear tmp/cache/* and restart Rails is getting tiring. If you look at the Sprockets source , you can see that if cache_classes is true then app.assets gets set to app.assets.index , and the filesystem is no longer checked. In order to get around this in development, you can add something similar to the following to your development.rb configuration: # Sprockets

Why does stylesheet_link_tag not link to /assets in production?

大憨熊 提交于 2019-11-30 06:52:52
I just did the first deploy for a new Rails 3.1 application, but the assets don't seem to work correctly. I'm precompiling everything upon deploy, and it turns up in public/assets like expected. However, the output of for example stylesheet_link_tag "application" in my layout has a href pointing to /stylesheets/application.css . This obviously does not work. The strange thing is that in development mode everything seems to be fine, it links to /assets/application.css like expected. I've compared my config/application.rb and config/environments/production.rb files with another app we have on