I have this file app/assets/stylesheets/config.rb with the following content:
http_path = "/"
css_dir = "."
sass_dir = "."
images_dir = "img"
javascripts_dir = "js"
output_style = :compressed
relative_assets=true
line_comments = false
what is it for?
To answer your question "what is it for", it's configuration for the Compass scss compiler. The reference in the other answer is handy, but for up to date details without speculation check out the details of the Compass configuration file here:
http://compass-style.org/help/tutorials/configuration-reference/
I had originally posted to also provide an answer for where the file came from (if you didn't create it yourself. I answer this because it was 'magially' appearing in my Rails project, and a Google search for generation of config.rb in Rails ends up here. I first supsected sass-rails, but someone from that project confirmed they don't generate that file. Then I figured out that auto-generation of this file was being caused by Sublime Text with the LiveReload package. See the related github issue.
I'm guessing that it defines how to find assets from the stylesheets folder, and some output options on what happens to the assets before being sent to the client browser.
http_path = "/" <= probably the root path to assets, so if you had
application.css, the URL path to it would be
http://example.com/application.css
css_dir = "." <= the directory to look for css files. "." in linux
means "the current directory", so this would set you
CSS path to app/assets/stylesheets
sass_dir = "." <= same as above, except for .sass/.scss files
images_dir = "img" <= images go in app/assets/stylesheets/img
javascripts_dir = "js" <= javascript go in app/assets/stylesheets/js
(seems like a strange place to put them)
output_style = :compressed <= either to produce .gzip'ed versions of files
or to minify them, maybe both - consult docs on this
relative_assets=true <= relative, as opposed to absolute paths to assets, I think
line_comments = false <= I think this turns on/off the ability to include comments,
or maybe whether the comments are included in the
compressed versions of the file. turn it to "true" and
compare the assets, as served to the browser, and see
what the difference is
You can fix it by removing Live Reload plugin from Sublime Text.
Sublime Text > Preferences > Package Control > Remove Package > Live Reload
For me it's good solution because I didn't using Live Reload.
Who using live reload please follow issue: github.
Related
I've been asked to remove any images duplicated in the war file our grails app is packaged in. The documentation suggests this is possible via the grails.assets.excludes property in Config.groovy, but it doesn't clearly state how this property is supposed to work.
Here's what the documentation says:
Optionally, assets can be excluded from processing if included by your require tree. This can dramatically reduce compile time for your assets. To do so simply leverage the excludes configuration option:
grails.assets.excludes = ["tiny_mce/src/*.js"]
The example is totally unclear to me. I've tried several permutations of this expression with no success; image assets continue to be preprocessed, causing duplicates of all of them in the resulting war file. Here are a few settings I've tried:
grails.assets.excludes = ["tiny_mce/src/*.jpg", "tiny_mce/src/*.jpg"]
grails.assets.excludes = ["<app_name>/src/*.jpg", "<app_name>/src/*.jpg"]
grails.assets.excludes = ["/images/*.jpg", "/images/*.png"]
grails.assets.excludes = ["**/*.jpg", "/images/**"]
What am I missing? How do I tell the asset pipeline to skip precompiling images?
This works for me:
grails.assets.excludes = ["**/*.jpg","**/*.png"]
I can't get any rule based on images/ to work...
When using the karma javascript test library (née Testacular) together with Rails, where should test files and mocked data go be placed?
It seems weird to have them in /assets/ because we don’t actually want to serve them to users. (But I guess if they are simply never precompiled, then that’s not an actual problem, right?)
Via this post: https://groups.google.com/forum/#!topic/angular/Mg8YjKWbEJ8
I'm experimenting with something that looks like this:
// list of files / patterns to load in the browser
files: [
'http://localhost:3000/assets/application.js',
'spec/javascripts/*_spec.coffee',
{
pattern: 'app/assets/javascripts/*.{js,coffee}',
watched: true,
included: false,
served: false
}
],
It watches app js files, but doesn't include them or serve them, instead including the application.js served by rails and sprockets.
I've also been fiddling with https://github.com/lucaong/sprockets-chain , but haven't found a way to use requirejs to include js files from within gems (such as jquery-rails or angularjs-rails).
We ended up putting tests and mocked data under the Rails app’s spec folder and configuring Karma to import them as well as our tested code from app/assets.
Works for us. Other thoughts are welcome.
Our config/karma.conf.js file:
basePath = '../';
files = [
JASMINE,
JASMINE_ADAPTER,
//libs
'vendor/assets/javascripts/angular/angular.js',
'vendor/assets/javascripts/angular/angular-*.js',
'vendor/assets/javascripts/jquery-1.9.1.min.js',
'vendor/assets/javascripts/underscore-min.js',
'vendor/assets/javascripts/angular-strap/angular-strap.min.js',
'vendor/assets/javascripts/angular-ui/angular-ui.js',
'vendor/assets/javascripts/angular-bootstrap/ui-bootstrap-0.2.0.min.js',
//our app!
'app/assets/javascripts/<our-mini-app>/**',
// and our tests
'spec/javascripts/<our-mini-app>/lib/angular/angular-mocks.js',
'spec/javascripts/<our-mini-app>/unit/*.coffee',
// mocked data
'spec/javascripts/<our-mini-app>/mocked-data/<data-file>.js.coffee',
];
autoWatch = true;
browsers = 'PhantomJS'.split(' ')
preprocessors = {
'**/*.coffee': 'coffee'
}
I found this project helpful as a starting point. https://github.com/monterail/rails-angular-karma-example. It is explained by the authors on their blog.
It's an example rails app with angular.js and karma test runner.
I have an app that works fine in on my development machine, but on my production server it uses a broken link to serve an image served using the Paperclip Gem.
Production environment is Linux(Debian), Apache, Passenger and I am deploying with Capistrano.
The app is stored in (a symlink that points to the public folder of the current version of the app deployed using capistrano):
/var/www/apps/root/appname
However, when I try and access it on the production server, the Apache error log displays this as the path it is looking in:
/var/www/apps/root/system
The correct path, however, is:
/var/www/apps/appname/shared/system
One option available to me is to create a symlink in root that directs system to the correct path, but I don't want to do this in case I want to deploy another app in the same root dir.
The url for this request is generated by rails, but Apache is what fetches the static resource (image files), so I have tried placing the following in my config/environments/production.rb:
ENV["RAILS_RELATIVE_URL_ROOT"] = '/appname/'
Which has resolved all other pathing issues I've been experiencing, but when rails generates the url (via the Paperclip gem), it doesn't seem to use it.
How can I set it so Paperclip uses the right path and only uses it production?
I've a workaround, add this as one of initializers:
config/initializer/paperclip.rb
Paperclip::Attachment.class_eval do
def url(style_name = default_style, options = {})
if options == true || options == false # Backwards compatibility.
res = #url_generator.for(style_name, default_options.merge(:timestamp => options))
else
res = #url_generator.for(style_name, default_options.merge(options))
end
# replace adding uri before res, minus final /
Rails.application.config.site_relative_url[0..-2]+res
end
end
At the moment Paperclip doesn’t work with ENV['RAILS_RELATIVE_URL_ROOT'] and the. You can follow the issue here:
https://github.com/thoughtbot/paperclip/issues/889
I'm trying to do some quite complicated configuration with uwsgi. I'm trying to make things easier on myself in the long run and naturally, in doing so, I'm making things as hard as could possibly be right now.
Anyway, I'm looking for the complete list of magic variables. The ones I've been able to find on the Emperor page are not what I'm after. The page (and others) suggests there's a larger dictionary of magic out there. Somewhere.
%v = the vassals dir
%o = the original config filename as specified in the command line
%p = the absolute path of the config filename
%s = the filename of the config file
%d = the absolute path of the directory containing the config file
%e = the extension of the config file
%n = the filename without extension
The uwsgi docs seem to have been updated since the time this question was asked. Here is a link to a longer list of magic variables:
http://uwsgi-docs.readthedocs.org/en/latest/Configuration.html#magicvars
the only missing variable is %c that reports he name of the directory containing the config file:
/foo/bar/test/one.ini will return 'test'
I have a file "settings.ini" which needs to reside next to the Qt executable.
I can add a custom build step for this in Qt Creator which calls something like this:
copy %{sourceDir}/settings.ini %{buildDir}/settings.ini
This works great so far, but I'd like to include this in the *.pro file so I can put this up in our SVN too.
How can I do this using qmake/.pro-files only?
To copy %{sourceDir}/settings.ini to the build directory without requiring to call make install use:
copydata.commands = $(COPY_DIR) $$PWD/settings.ini $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
$$PWD is the path of current .pro file. If your settings.ini file is not located in the same directory than the project file, then use something like $$PWD/more_dirs_here/settings.ini
Note: I found this solution here. I recommend to read the whole article as it explains how it works.
You probably want to use the INSTALLS keyword in QMake. It will require you to run make install after your build, but it does work cross-platform.
install_it.path = %{buildDir}
install_it.files += %{sourceDir}/settings.ini
INSTALLS += install_it
for osx bundles you can handle it this way
see Resource files in OS X bundle
add this to you project file:
APP_QML_FILES.files = path/to/file1.qml path/to/file2.qml
APP_QML_FILES.path = Contents/Resources
QMAKE_BUNDLE_DATA += APP_QML_FILES
this example copies the files to Contents/Resources
Compatible with Windows and Mac OSX Dev environments:
Change {AppName} to respective application name
# Define mac/windows specific target dirs
TARGETDIR = ''
macx {
TARGETDIR += $$OUT_PWD/{AppName}.app/Contents/MacOS/
}
else {
TARGETDIR += $$OUT_PWD
}
# Directories do not exist for the first build
# Without mkdata, build is successful after 5 tries. To avoid, use mkdata
mkdata.commands = $(MKDIR) $${TARGETDIR}
copydata.commands = $(COPY_FILE) $$PWD/settings.ini $${TARGETDIR}
first.depends = $(first) mkdata copydata
export(first.depends)
export(mkdata.commands)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first mkdata copydata
Happy to add Unix support if someone posts Unix solution in the comments.